Reputation: 2139
I've one appwidget class and I need to create few widgets but each of them must storage other data set in WidgetConfigure. Clicked widget should show activity with this data. I save my data to shared preferences and read it in widget, but if i try add next widget, it override existing data. How can i do that? I was tried something like that
configEditor.putInt("a"+mAppWidgetId, a_num); //it's in widgetconfigure class
int a = config.getInt("a"+mAppWidgetId, 0); //widget class
I've no idea how to solve it. After update all widget contain the same data.
Upvotes: 1
Views: 1291
Reputation: 20936
Actually, you're right. If you need to store different values for different widget instances you should append id value of the widget to the key. A possible way how to do this is described in the book Pro Android 3
.
But if you want to store only one integer there is other way to do this. Look here for more details.
Upvotes: 3