Using the updateAppWidgetOptions method for the AppWidgetManager to store widget settings

I have three questions about application widgets:

1) . If I want to add a parameter value to the application widget parameters, I should always first get widget parameters using getAppWidgetOptions(int) and then manipulate the Bundle , otherwise I will call updateAppWidgetOptions(int appWidgetId, Bundle options) I will overwrite other existing options, right?

2) Do you have reboot options? Ie, if I store some information related to widgets as part of customization activities, I am sure that someday I will find them even after a reboot? Does the system automatically save them somewhere?

3) Is it faster than saving widget settings in general settings?

+6
source share
2 answers

updateAppWidgetOptions designed to launch launchers for transmitting information to widgets. Widgets receive this information in onAppWidgetOptionsChanged . Widgets do not store information this way, and if they try, they will be overwritten by the launcher.

+5
source
  • Yes, probably. If you want to be sure, I suppose you should just check it out.

  • I do not think so. You need persistent storage such as SQLite DB or Shared Preferences to survive the reboot.

  • Perhaps because it is memory based (SharedPrefs are file based).

+2
source

Source: https://habr.com/ru/post/922236/


All Articles