I have replaced SQLiteOpenHelper with import net.sqlcipher.database.SQLiteOpenHelper
For inserting datas into Database and getting data from it, I have used
SQLiteDatabase db = this.getWritableDatabase("mypassword");
instead of below
SQLiteDatabase db = this.getWritableDatabase();
Below is my oncreate and onUpgrade,
@Override
public void onCreate(net.sqlcipher.database.SQLiteDatabase db) {
db.execSQL(ARecords.CREATE_TABLE);
db.execSQL(BRecords.CREATE_TABLE);
}
@Override
public void onUpgrade(net.sqlcipher.database.SQLiteDatabase db, int oldVersion, int newVersion) {
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS " + ARecords.TABLE_NAME);
db.execSQL("DROP TABLE IF EXISTS " + BRecords.TABLE_NAME);
//Create tables again
onCreate(db);
}
In MainActivity,
SQLiteDatabase.loadLibs(this);
below is my dependencies
implementation 'net.zetetic:android-database-sqlcipher:4.4.3'
implementation 'androidx.sqlite:sqlite:2.1.0'
I am using SQLCipher for preventing my application from attacker gets access to the data stored in the /data/data/com.applicationname/ directory
Rooted devices can have access to the data/data/com.applicationname/ directory right.Then using SQLCipher wont allow users to the directory ?
- Now I want to make sure whether my database is now secured. How to know that?
- I am using hardcoded passwords inside getWritableDatabase. Is that good way to do? Or it may be hacked?
Also I have seen below tutorial for Encryption. So now I am confused. Using SQLCipher itself good or need to do like below tutorial
Thanks in Advance
from Is my SQLite Database is secured after using SQLCipher?
No comments:
Post a Comment