Best approach when working with existing SQLite database in StorIO

812 Views Asked by At

Was just wondering if there is a suggested approach when working with a existing data with StorIO? I will like to ship my app with a lot of existing data. Should I copy my .db from assets to db folder on first launch or is there anything better I can do? Thanks!

1

There are 1 best solutions below

2
On BEST ANSWER
  1. Create prefetched SQLite database.
  2. Put created db file into assets folder.
  3. Write custom SQLiteOpenHelper where you should copy db from assets folder to the db folder of the application data at first time when it's opened. Or you can use Android SQLiteAssetHelper library.
  4. Pass your SQLiteOpenHelper or SQLiteDatabase to the StorIOSQLite.

StorIOSQLite storIOSQLite = new DefaultStorIOSQLite.Builder()
  .db(yourPrefetchedDb)
  // add types mappings if you need
  .build();

That's the easiest way :)

May be you can download data from remote source (server) instead of placing it into the assets?

Because prefetched database will be part of the apk and increase its size and you can not remove this file at runtime.