Code Vader
Code Vader

Reputation: 755

Quickest way to access data

I am planning the design of a language learning application. I want a TextView to be able to change between about 400 phrases, however I don't want to hardcode this. I want to make something like a text file with all the phrases stored in there. Then I can change the content of the text file without worrying about having to change my code.

What will be the best way to access the phrases? Should I store them all in the SQLite database? Or should I rather create a text file and store it in the app's resources, and then read from there? Should I use a content provider?

Is there another, better solution?

Upvotes: 0

Views: 64

Answers (3)

Marcos B.
Marcos B.

Reputation: 495

I would recommend you read first the official documentation to know which is the better solution for you.

Storage Options

Now, in my personal opinion, I would use the internal storage (a file) for that. Simple and easy access to the information.

Upvotes: 0

Chintan Rathod
Chintan Rathod

Reputation: 26034

Option 1

you should go for a file having XML or JSON data inside. Both approach is using "key" - "value" pair concept. If you don't know about them,

  1. XML
  2. JSON

If your content, doesn't matter in XML or JSON, is true then if you change it with value, you are done with. What you need to maintain is the format only.

Proc

  • If you have predefined format of your phrases, if you change the file, it will parse automatically.
  • No need to maintain

Option 2

You can go with database. But then you need to do entry of data or you need to have database file to replace it.

Cons

  • Entry in database is the main thing you need to think about

Upvotes: 0

upenpat
upenpat

Reputation: 685

You can use ORM libraries like ORMLite or greenDAO. It will be simple and also suit your application.

Upvotes: 2

Related Questions