JuanDYB
JuanDYB

Reputation: 744

Deploy Android Application with Initial SQLite database

I need to use a Database in Android and I have read that a good way at the moment is using Room Library. But my case is a little different I don't want the database to write information on runtime I want to deploy the application with an SQLite dabase already created and with data inside.

What is the folder to put the DB file in Android Studio project? How to access this from app using Room?

Thanks

Upvotes: 0

Views: 397

Answers (2)

Sam Raju
Sam Raju

Reputation: 199

use this library implementation'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'

and paste the database in your asset folder and in your sql helper call put the database name

 private class SqL extends SQLiteAssetHelper{

    public SqL(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }
}

where DATABASE_NAME is your databse name and DATABASE_VERSION is your database version

Upvotes: 1

Ankit Gomkar
Ankit Gomkar

Reputation: 27

Put db file at your project assets folder

Upvotes: 0

Related Questions