-2

I am developing an android app which handles a lot of text. I'm confused at the data storage and retrieval, Which one should i use for faster data retrieval? Sqlite or file storage (json files, separate file for each category ). First I thought about sqlite because it is more easy to manage data, but it will take sometime to create tables with almost 1000 rows in each table or i have to ship the database with my app and it will increase the download size and then i thought about file storage. Which one should i use, sqlite or json file as the data creation is a one time process an the rest is retrieval? Can anyone suggest a better way, i'm really, really confused.

Sony
  • 7,136
  • 5
  • 45
  • 68
  • 1
    You dont need to ship sqlite database with your application if it has only structure and no data. You can create sqliteDatabase dynamically and create tables using queries – Abdul Saleem Mar 05 '15 at 15:36
  • it should contain data in the first launch – Sony Mar 05 '15 at 16:29
  • What about data retrieval? which one is faster, sqlite or file storage – Sony Mar 05 '15 at 16:33

2 Answers2

1

If you have a lot of text and data, use greenDAO. It will handle your SQLite related stuff. It's a bit confusing at start, but once you tried it you will never use SQLite on Android without it:

http://greendao-orm.com/

Some interesting links: http://developer.android.com/guide/topics/data/data-storage.html http://developer.android.com/training/basics/data-storage/index.html

Patrick Dorn
  • 756
  • 8
  • 13
1

Assuming that the table creation only happens once when the app is installed, then unless the table creation is very, very slow you can simply do it at app first install and include some appropriate message to the user on the screen.

Ideally, if your app can do other useful things without using the data then you can let the user use other parts of the app while the table creation completes in the background.

I have found from past experience that creating very large simple tables is actually very fast, but you would need to test to see how long your examples take.

Note also that you have the option, through the onUpgrade method of the SQLiteOpenHelper, to only modify the parts of the database that you need to at upgrade times, so you may not have to recreate the full data base when installing new versions of the app. This also includes mechanisms to avoid delaying app startup by deferring the updates until the database is first used, although that may not be what you want in this case.

Mick
  • 24,231
  • 1
  • 54
  • 120
  • What about data retrieval? which one is faster, sqlite or file storage? – Sony Mar 05 '15 at 16:32
  • 1
    I think the answer is unfortunately that it will depend on your needs - if you have no complex relationships etc and really just need to read in a stream of bytes then flat files sound intuitively faster, but I would still test as intuition can be dangerous in computing performance design decisions (for example because common slow tasks get targeted for optimisation at lower layers and end up much quicker than you might expect). There is some good discussion here also: http://stackoverflow.com/a/2357027/334402 – Mick Mar 05 '15 at 17:12