Compare and contrast the usage of SQLite, Room Persistence Library, and Shared Preferences. When would you choose one over the others, and what factors should be considered in making this decision?
rohanmuthannaBegginer
What are the different approaches for implementing data persistence in Android applications?
Share
For a Beginner one can use
1.Shared Preferences
2.SQLite
-When you need to store a single data unit for example high score in a game
It’s better to use shared preferences
-When you need to store a list of data that is being updated again and again by user for example creating a playlist in app
The user creates multiple playlists in apps and the new playlists need to be inserted in a list where previous playlists were stored
so it’s an ArrayList that is being stored in database the ArrayList can be of particular ModelType/DataType
In such a case it’s better to use SQLite
While using SQLite it’s good to create a DatabaseHelper class with insertItems and getItems methods as decalred Static
If you want a example of code I can post it!