我目前正在跟随Mark Murphys SQLite android教程。我偶然发现了SQLCihper,它能够在数据从设备中拔出时使数据无法读取。我制作了自己的示例应用程序,DB和MainActivity完美运行。我能够从模拟器中取出数据库,并且能够使用SQLite browser读取数据库的内容。然后我按照另一个stackoverflow问题的这些“简单”说明进行操作,但我收到了错误。
以下是我的示例应用中的MainActivity中的onCreate:
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
DBHelper db = new DBHelper(this);
db.getReadableDatabase();
同样,上面的代码工作正常。
接下来,我尝试将我的示例应用与SQLCipher集成:
所以现在我的MainActivity onCreate代码如下所示:
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
DBHelper db = new DBHelper(this);
db.getReadableDatabase("sekrit");
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)
答案 0 :(得分:0)
看起来你们都在问题的评论中对它进行了整理,但是为了参考和其他任何人,我们在这里有一个SQLCipher和Android项目的集成教程,其中包含loadLibs位; - )
http://sqlcipher.net/sqlcipher-for-android/
正如@CommonsWare建议的那样,欢迎所有人将问题发布到SQLCipher用户邮件列表中: