I have a widget and I want to save its state when it’s being clicked.
Currently I’m saving the state with SharedPreferences.
This works but it is relatively slow to commit updates to the preferences.
Are there any better solutions?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If by “widget” you mean “widget”, this makes no sense. At most, a widget should be communicating with its hosting activity. The activity can save its state at appropriate times using appropriate means.
If by “widget” you mean “app widget”, this makes more sense.
All writes to flash are slow, by flash’s nature. Where possible, committing
SharedPreferencesshould be done in the background. On Android 2.3 and higher, you have a newapply()method that does that automatically.