Question

I'm currently developing a media player application for Android. Now, I would like to store the last played songs. Which approach for persistence should I take to do this ? I mean, should I use SharedPreferences, o perhaps SQLLite database, or something else ?

I would settle for save the songs ID in some specific order. It's not necessary to save the title, artist or album of the song.

Was it helpful?

Solution

You must have seen all the Storage Options that android provides. If you read the SharedPreference part, it provides a general framework that allows you to save and retrieve persistent key-value pairs of primitive data types. It also supports saving sets and ArrayList. See Save ArrayList to SharedPreferences questions. If you just want to store the last played song ID's, then using SharedPreference might be preferable. It is also faster than using database.

However, if you have more structured data, then using database might be better to manage. To know more about when SharedPreference would be good to use and when SQL Lite database, read Pros and Cons of SQLite and Shared Preferences .

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