is there any pro and cons of using both in a single program can we use both shared preference and sqlite in android ? Is this even possible to use ?
-
Its depends on your requirement, Basically what you trying to do,else there is no issue in using both. – RobinHood Mar 13 '15 at 06:20
-
Yes You can Use Both. – Imtiyaz Khalani Mar 13 '15 at 06:20
-
What is mean of single program? Are you talking about an application? – Pankaj Kumar Mar 13 '15 at 06:20
-
Sure you can use both. – Ebin James Mar 13 '15 at 06:35
4 Answers
is there any pro and cons of using both in a single program ?
Yes, and they depend on your usage, Normally Shared preferences are used for storing information which is smaller in size (typically in bytes), where you don't want to do extra work of involving SQLite in picture. SQLite is preferred for storing bulkier information.
can we use both shared preference and sqlite in android ?
Yes,
Is this even possible to use ?
Yes

- 13,134
- 17
- 77
- 148
Its possible, you should store settings
, flags
and one line String
in SharedPrefrence
and any other relational data with multiple filed should go in sqlite

- 3,484
- 3
- 33
- 56
Yes you can use both depending upon your needs,sqlite basically for storing heavy info like big texts picture,audio files and shred pref for simple key value pairs,infact when your data is huge you should consume content through rest services in your android app.

- 576
- 5
- 17
Yes, you can use both SharedPreference
and SQLite
at the same time depending on your requirements. You can read about different storage options used in android from here
This question is asked before. Pros and Cons of SQLite and Shared Preferences but I want to add some links for you to understand more specifically.
SharedPreferences: SharedPreference
is used to store small data. You can use more than one SharedPreference
in your application depending on your requirements. You can learn about it from Android Developer site.
SQLite: Sqlite is a database use by android to store some how large amount of data as compared to sharedpreferences. There are many tutorials about SQLite
one of the popular tutorial you can follow this link
For Example: There is a common scenario mostly used in android applications is User Login process. You can maintain session of user login using SharedPreference
and you can store User Bio data in SQLite
like Username, email, contactNo, Organization etc and perform updation, deletion using SQLite
database queries. There is an complete implementation of User Login Session Management you can follow this link.
Hope it will help you.

- 1
- 1

- 2,857
- 2
- 27
- 47