I have a sqlite file with an extension of (db_name.sqlite) and i want to reuse this database in my android project instead of creating new one because, this database has huge data stored in it.
How is it possible?
I have a sqlite file with an extension of (db_name.sqlite) and i want to reuse this database in my android project instead of creating new one because, this database has huge data stored in it.
How is it possible?
If your "huge data" is less than 50MB, you can package the database as an asset and then unpack it on first run of your app. I recommend SQLiteAssetHelper
for this.
Once your APK grows to 50MB, though, things get a bit more complicated, as you would need to either download the database yourself or look into APK Expansion Files.
Once you have the SQLite database in place, you can use it the same way as you use any other SQLite database in Android. SQLiteAssetHelper
will offer the same getReadableDatabase()
and getWriteableDatabase()
methods you see in SQLiteOpenHelper
, giving you a SQLiteDatabase
object on which you can run queries, etc.