all are known difference between SQLite, Content provider and Shared Preference.

But i want to know when i need to use SQLite or Content provider or Shared Preference by situation.

Please explain with some examples.

有帮助吗?

解决方案

Its all depends on your data usage,

  • Content Provider is used to Share data between applications
  • SharedPreference is used to Store small size of information like "read me" option in Login page, where you store userId & password in SharedPreference to skip login screen in future
  • Sqlite is used when you have large size of structure data. Sqlite also allows you to use query for searching particular data.

其他提示

shared preferences are the location where you can store the secret information for your app, like setting cookies in the browser, this can be used for login credentials and other.

where as content provider stores and retrieves the data and make it available to other applications also. like suppose you want to access the contacts available in the android phone, they can be accessed by content providers

Reference Links: Difference between Shared Preferences and Content Providers in android

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top