Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top