Widget stores android data

I created an RSS feed widget, but my problem is how to temporarily store the cause of the rss feed data, when I put the phone to sleep and then try to iterate through the widget, a static public variable loses all the data. It is very similar to the facebook widget with two arrows.

What is the best way to store Android widget data?

+4
source share
2 answers

It loses data in its member variables because the object (I assume WidgetProvider) is really thrown by Android. In fact, you will never see the same instance again!

So, as already mentioned: save your data in SharedPrefs (for "little things") or even in the database, if it is more. In your case, I assume that you need a ContentProvider for your data (which, in turn, will most likely have a database or a flat file server)

0
source

Data storage is set on a daily basis. I'm sure.

http://developer.android.com/guide/topics/data/data-storage.html

SharedPreferences or SQLiteDatabases are the most common ways. SharedPreference will be fine in your case, I think.

0
source

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


All Articles