Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7603629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:42:22+00:00 2026-05-30T23:42:22+00:00

I am taking datas from the users and storing into the database. My database

  • 0

I am taking datas from the users and storing into the database. My database takes only one value. So each time the user enters the database the database is updated. I show these datas in the textview of the AppWidget.For that I use this code:

public void onUpdate(Context context, android.appwidget.AppWidgetManager appWidgetManager, int[] appWidgetIds) {

    //Get all ids
    ComponentName thisWidget = new ComponentName(context.getPackageName(),SmsSchedulerWidget.class.getName());

    int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);


    //the datas to be shown are fetched from the database
    DatabaseManager dbManager = new DatabaseManager(context);
    dbManager.open();
    contactNumber = dbManager.fetchContactNumber();
    Log.i("contactNumber",contactNumber);
    date = dbManager.fetchDate();
    Log.i("date",date);
    message = dbManager.fetchMessage();
    Log.i("message",message);
    status = dbManager.fetchStatus();
    Log.i("status", status);
    dbManager.closeDatabase();
    //Build the intent to call the service

    //it creates the UI for the given app widget
    RemoteViews remoteViews = new RemoteViews(context.getPackageName(),R.layout.schdulesms_appwidget_layout);


    remoteViews.setTextViewText(R.id.to_appwidget_saved_data,
            contactNumber);
    remoteViews.setTextViewText(R.id.date_appwidget_saved_data, date);
    remoteViews.setTextViewText(R.id.status_appwidget_saved, status);
    remoteViews.setTextViewText(R.id.message_appwidgset_saved_data,
            message);

    //to start the activity with the click on the layout
    Intent clickIntent = new Intent(context.getApplicationContext(),MainActivity.class);
    clickIntent.setFlags(clickIntent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pendingIntent= PendingIntent.getActivity(context, 0, clickIntent, 0);
    remoteViews.setOnClickPendingIntent(R.id.full_widget, pendingIntent);

    //to update the BroadCast Receiver so that it holds the current values in the layout
    Intent updateIntent =new Intent(context,SmsSchedulerWidget.class);

    updateIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
    updateIntent.setComponent(thisWidget);

    PendingIntent pendingIntentForUpdate = PendingIntent.getBroadcast(context, 0, updateIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    remoteViews.setOnClickPendingIntent(R.id.logoBtn, pendingIntentForUpdate);

    appWidgetManager.updateAppWidget(thisWidget, remoteViews);

    }

My app widget should update itself after the button click and as well as the user has entered new values into the database at run time.But the app widget only updates itself after the appwidget is uninstalled from the screen and then installed again or the program is rerun.Why is this happening? How to update my app widget after the click of the button?????

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:42:23+00:00Added an answer on May 30, 2026 at 11:42 pm

    To manually update your AppWidget, you must send it a Broadcast and receive it in your AppWidgetProvider‘s onReceive() method. From the onReceive() you should extract all the values you need from the broadcast Intent and then call the onUpdate() method manually. Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating files based on user data (taking from the database table, writing to
Inserting rows one by one from a 600 record data-set is taking almost an
Quick question regarding database design; Given I'm storing User data in a database, I
I'm using ADO to save data to an MS Access database. It was taking
Taking over some code from my predecessor and I found a query that uses
Here's the question first: Is this possible? I'm taking my inspiration from Joe Wrobel's
We frequently have users that create multiple accounts and then end up storing the
I've done a couple of integrations that are similar. In one, I was taking
I'm trying to transfer data from a DataSet into an Excel workbook. Unfortunately, I
Scenario - It is an simple application through which only single user ( NO

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.