How to load existence sqlcipher db from assets/databases in android studio?


#1

Hi, I created a sqlcipher database. Now i want to put it in asset/databases folder of my android studio project. How can I use this database in my project? I put it in asset/databases but when I use this code it seems that it make an empty database(I mean that the application never used the database that I put in assets folder):

SQLiteDatabase.loadLibs(this);
File databaseFile=null;
databaseFile=getDatabasePath(“temp.db”);
databaseFile.mkdirs();
databaseFile.delete();
SQLiteDatabase sq=SQLiteDatabase.openOrCreateDatabase(databaseFile, “kvlhtchvahcshgj,gdn70”, null);

how can I use my existing database?


#2

Hello @Zahra_Tofighi

You will need to extract your database from the assets directory. You might take a look at how that is done within the SQLCipher for Android test suite.