开发者

Android App Widget: Data storage

I'm implementing a home screen app widget. I was wondering which is better开发者_高级运维 to store/read data: SharedPreferences or a SQLite database? The data is accessed from an AppWidgetProvider (similar to a BroadcastReceiver), and any given instance of the widget displays different data based on appWidgetId. Is one way or the other frowned upon?


It really depends on your use case. Preferences are meant to be a simple, lightweight mechanism to store key-value type of data while an SQLite database provides you with a whole framework for storing and retrieving relational data (queries, transactions, etc.).

This article gives an overview of both and also covers custom files and network as alternative ways to persist data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜