Say that there is an App Widget that shows a configuration Activity when placed. The configuration page allows adjusting the appearance of t开发者_如何学运维he widget.
The user may place multiple instances of this widget on their home screen. What would be the best way to maintain the unique configuration states on each of the widget instances? Or would each widget instance have to adopt the same global state?
I know this is an old post, but...
I am doing it by writing a file identified/named as the widgetId. When the phone is rebooted the widgetId is maintained and my widget reads the file. Each time I configure each widget it writes to its own file until the widget is deleted from the screen and recreated.
I have heard that it is best to use SQLlite instead of files, but I have not looked into that yet.
精彩评论