tags:

views:

195

answers:

1

I am creating a simple Android widget with a typical usecase of having many instances of it running at once.

Using the stock preferencesmanager, it seems each instance of the widget shares the same preferences.

Is there any way to not have this happen?

Thanks!

+1  A: 

You can try overriding getPreferenceManager() in your PreferenceActivity, and return a custom PreferenceManager in which you have overridden getPreferences() to return a different SharedPreferences object for each app widget. I have not tried this, so I am not completely certain it will work. If it does, and you think of it, comment on this answer to let me know!

CommonsWare
Interesting idea. I ended up just prefixing preferences with their widget ID - dirty, but a lot of the API docs do it the same way, just took some digging. See: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/appwidget/ExampleAppWidgetConfigure.html
NPike