I'm currently following along with Mark Murphys SQLite android tutorials. I stumbled upon SQLCihper and it's ability to make data unreadable when it's pulled off of a device. I made my own sample application, and the DB and MainActivity work perfectly. I'm able to pull the database off the emulator and I'm able to read the contents of the database using SQLite browser. I then followed these "simple" instructions from another stackoverflow question but I am getting errors.
Here is my onCreate in my MainActivity in my sample app:
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
DBHelper db = new DBHelper(this);
db.getReadableDatabase();
Again, the above code works fine.
Next I tried to integrate my sample app with SQLCipher:
- Copied the icudt46l.zip into /assets
- Copied three .so files into /armeabi
- Copied three .so files into /x86
- Copied three jars into /libs
- Changed my imports in my DBHelper class to use the API from SQLCipher
- Added a parameter to getReadableDatabase();
So now my MainActivity onCreate code looks like this:
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
DBHelper db = new DBHelper(this);
db.getReadableDatabase("sekrit");
The logcat:
06-20 20:50:33.178: E/AndroidRuntime(24805): FATAL EXCEPTION: main
06-20 20:50:33.178: E/AndroidRuntime(24805): java.lang.UnsatisfiedLinkError: Native method not found: net.sqlcipher.database.SQLiteDatabase.dbopen:(Ljava/lang/String;I)V
06-20 20:50:33.178: E/AndroidRuntime(24805): at net.sqlcipher.database.SQLiteDatabase.dbopen(Native Method)
06-20 20:50:33.178: E/AndroidRuntime(24805): at net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:1950)
06-20 20:50:33.178: E/AndroidRuntime(24805): at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:900)
06-20 20:50:33.178: E/AndroidRuntime(24805): at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:943)
06-20 20:50:33.178: E/AndroidRuntime(24805): at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:107)
06-20 20:50:33.178: E/AndroidRuntime(24805): at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:173)
06-20 20:50:33.178: E/AndroidRuntime(24805): at com.example.testsqlcipher.MainActivity.onCreate(MainActivity.java:65)
06-20 20:50:33.178: E/AndroidRuntime(24805): at android.app.Activity.performCreate(Activity.java:5104)
06-20 20:50:33.178: E/AndroidRuntime(24805): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
06-20 20:50:33.178: E/AndroidRuntime(24805): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
06-20 20:50:33.178: E/AndroidRuntime(24805): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-20 20:50:33.178: E/AndroidRuntime(24805): at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-20 20:50:33.178: E/AndroidRuntime(24805): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-20 20:50:33.178: E/AndroidRuntime(24805): at android.os.Handler.dispatchMessage(Handler.java:99)
06-20 20:50:33.178: E/AndroidRuntime(24805): at android.os.Looper.loop(Looper.java:137)
06-20 20:50:33.178: E/AndroidRuntime(24805): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-20 20:50:33.178: E/AndroidRuntime(24805): at java.lang.reflect.Method.invokeNative(Native Method)
06-20 20:50:33.178: E/AndroidRuntime(24805): at java.lang.reflect.Method.invoke(Method.java:511)
06-20 20:50:33.178: E/AndroidRuntime(24805): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-20 20:50:33.178: E/AndroidRuntime(24805): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-20 20:50:33.178: E/AndroidRuntime(24805): at dalvik.system.NativeStart.main(Native Method)