Steffen Waldmann
Steffen Waldmann

Reputation: 11

Data Storage - which approach for a song-lyrics-app?

I want to write an android app that basically shows titles of songs in a list view, and by selecting one song in the list, the lyrics of that sing are shown in a textview. In a second step there would be maybe a translation of the lyrics for every song.

So far nothing too complicated, but since I'm completely new to android programming, I wonder what's the best approach to store the data (i.e. the song titles/lyrics). I thought about a single (xml?)-file for each song where the filename is the title and the file contains the lyrics. I think that would make it easy to add new songs. where would such files be stored typically? /res/xml?

Or would another approach be more suitable? database storage? content provider?

Upvotes: 1

Views: 1000

Answers (2)

Timothée Jeannin
Timothée Jeannin

Reputation: 9912

According to the documentation about Data Storage, you have several options.

But the storage strategy that seems to meet your needs is an SQLite Database.

You can make use of SQLiteOpenHelper and ContentProvider to get it working.

It will require quite an amount of work and understanding to implement it but it's worth the effort :

  • Esier than other solutions to manipulate data once it stored.
  • A lot of android component are designed to work with databases cursors.
  • Easy to add new data and structures as your application evolves.
  • You will learn a lot about how develop android apps "the right way".

If i were you i would avoid :

  • SharedPreferences because this is not suited for list of data as there isn't any "id mechanism". On the other hand it is pretty easy to use for small settings.

  • Internal Storage because it is difficult to manipulate the data once it is stored. Also it is not the recommended way to store that type of data.

Upvotes: 1

Ian Warwick
Ian Warwick

Reputation: 4784

I would use a database and a content provider since it becomes very trivial to bind the content to ListViews using the Loader API.

Upvotes: 2

Related Questions