i am developing an apps where i have to stored 30 to 50 friend contacts, Name,phone and password, i have two option shared preference and sql lite, so which one i should use so that it got less storage and could't waste many memory and which one will be faster during searching any contacts no or item ?
-
Does this answer your question? [Pros and Cons of SQLite and Shared Preferences](https://stackoverflow.com/questions/6276358/pros-and-cons-of-sqlite-and-shared-preferences) – General Grievance Oct 06 '22 at 15:24
3 Answers
You should definitely use SQLite for that kind of data and requirements.
SharedPreferences are intented for saving preferences (hence the name), not for structured data resp. large amounts of data. Also with SQL you have ways of filtering and sorting the data, e.g. select * from contact where lastname like 'A%' order by firstname
to get all contacts where the lastname starts with an A and have them sorted by their first name (just for example).

- 23,362
- 7
- 71
- 86
I think that the best solution depends from how the app must be developed now and in the future. If you want to develop an app that can't change in the future ( for example the contact must be ever name, phone and password ) you can use a solution "Quick and Dirty" save on the shared preferences a key-value set and don't lose any time on it. But if the informations can change and the app can have some improvements...is more usefull to create a object contact and a data structure to manage it.
If the contacts are a few number, you don't care about the performances. 50 records direct access to the id of the user have a good performance on SQLite.

- 1,775
- 21
- 33
SQLite (data is complex type and data is in large amount)
SharedPreferences(data is small, data is premitive type and you don't want to share it with user)

- 13,753
- 3
- 39
- 54