Difference between sqlite and shared preferences in android

Storing app data is an essential requirement of most applications. Android lets your store data using Shared Preferences and Sqlite database. You can use either of them, based on your requirement.

Shared Preferences

Shared Preferences stores data as key-pairs only. Key is required to read data from it. Reading amd storing data in it is very simple .But, it’s difficult to store and read large structured data . It saves  primitives data type like string, int ,booleans, floats ,long etc. It is best to use Shared Preferences when only small amount of data needs to be stored eg few app settings, user login /password etc.

Sqlite Database

It stores structured data as a database. The data can be queried and hence ,this makes it possible to search database. Reading data from sqlite database is slower and more expensive then shared preferences. SQLite database is useful for just about anything and very flexible. It is best to use Sqlite when the data to be stored is large , structured and required searching .eg storing complete user details , storing data fetched by http request etc.

Related Posts:

PreferenceActivity in Android

Using shared preferences in android


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s