Android Application Widget: Data Storage

I am implementing a home screen app widget. I was wondering what is the best way to store / read data: SharedPreferences or SQLite database? Data is accessed from an AppWidgetProvider (similar to BroadcastReceiver), and any given widget instance displays different data based on appWidgetId. One or the other frowned?

+4
source share
1 answer

It really depends on your use case. Preferences are designed for a simple and easy key-value data storage mechanism, and the SQLite database provides you with the whole structure for storing and retrieving relational data (queries, transactions, etc.).

This article provides an overview of both, and extends to user files and the network as alternative ways to save data.

+3
source

Source: https://habr.com/ru/post/1309168/


All Articles