问题描述
我试图用sqlcipher lib添加到我的数据库中已经存在的数据库进行加密,但在访问旧数据库(即打开DB)给出了这样的例外:
02-27 13:12:21.231:E / AndroidRuntime(14687):致命异常:主要
02-27 13:12:21.231:E / AndroidRuntime(14687):java.lang.RuntimeException的:无法启动的活动ComponentInfo {net.sqlcipher / example.SQLDemoActivity}:net.sqlcipher.database.SQLiteException:文件被加密或不是一个数据库
02-27 13:12:21.231:E / AndroidRuntime(14687):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
02-27 13:12:21.231:E / AndroidRuntime(14687):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
02-27 13:12:21.231:E / AndroidRuntime(14687):在android.app.ActivityThread.access $ 600(ActivityThread.java:149)
02-27 13:12:21.231:E / AndroidRuntime(14687):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1300)
02-27 13:12:21.231:E / AndroidRuntime(14687):在android.os.Handler.dispatchMessage(Handler.java:99)
02-27 13:12:21.231:E / AndroidRuntime(14687):在android.os.Looper.loop(Looper.java:153)
02-27 13:12:21.231:E / AndroidRuntime(14687):在android.app.ActivityThread.main(ActivityThread.java:4987)
02-27 13:12:21.231:E / AndroidRuntime(14687):在java.lang.reflect.Method.invokeNative(本机方法)
02-27 13:12:21.231:E / AndroidRuntime(14687):在java.lang.reflect.Method.invoke(Method.java:511)
02-27 13:12:21.231:E / AndroidRuntime(14687):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:821)
02-27 13:12:21.231:E / AndroidRuntime(14687):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
02-27 13:12:21.231:E / AndroidRuntime(14687):在dalvik.system.NativeStart.main(本机方法)
02-27 13:12:21.231:E / AndroidRuntime(14687):由:net.sqlcipher.database.SQLiteException:文件加密或不是一个数据库
02-27 13:12:21.231:E / AndroidRuntime(14687):在net.sqlcipher.database.SQLiteDatabase.native_setLocale(本机方法)
02-27 13:12:21.231:E / AndroidRuntime(14687):在net.sqlcipher.database.SQLiteDatabase.setLocale(SQLiteDatabase.java:2102)
。02-27 13:12:21.231:E / AndroidRuntime(14687):在net.sqlcipher.database.SQLiteDatabase< INIT>(SQLiteDatabase.java:1968)
02-27 13:12:21.231:E / AndroidRuntime(14687):在net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:901)
02-27 13:12:21.231:E / AndroidRuntime(14687):在net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:944)
02-27 13:12:21.231:E / AndroidRuntime(14687):在net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:107)
02-27 13:12:21.231:E / AndroidRuntime(14687):在example.SQLDemoActivity.onCreate(SQLDemoActivity.java:42)
02-27 13:12:21.231:E / AndroidRuntime(14687):在android.app.Activity.performCreate(Activity.java:5020)
02-27 13:12:21.231:E / AndroidRuntime(14687):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
02-27 13:12:21.231:E / AndroidRuntime(14687):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
02-27 13:12:21.231:E / AndroidRuntime(14687):11 ...更多
因为我的旧的数据库没有加密,因此在这种情况下应该怎么设置密码
我在密码字符串,并以,但没有运气试图用传球空
报告的问题,以 https://github.com/sqlcipher/android-database -sqlcipher /问题/ 124
SQLCipher为Android可以通过打开一个未加密的数据库,
作为密码。
然后:
- 您有一个错误在你的code,或
- 在该数据库已加密,另一个密码,或者
- 在该数据库已损坏。
I'm trying to use sqlcipher lib to encrypt my database from already existing database but while accessing the old database(i.e opening the db) gives this exception:
02-27 13:12:21.231: E/AndroidRuntime(14687): FATAL EXCEPTION: main
02-27 13:12:21.231: E/AndroidRuntime(14687): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.sqlcipher/example.SQLDemoActivity}: net.sqlcipher.database.SQLiteException: file is encrypted or is not a database
02-27 13:12:21.231: E/AndroidRuntime(14687): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
02-27 13:12:21.231: E/AndroidRuntime(14687): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
02-27 13:12:21.231: E/AndroidRuntime(14687): at android.app.ActivityThread.access$600(ActivityThread.java:149)
02-27 13:12:21.231: E/AndroidRuntime(14687): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
02-27 13:12:21.231: E/AndroidRuntime(14687): at android.os.Handler.dispatchMessage(Handler.java:99)
02-27 13:12:21.231: E/AndroidRuntime(14687): at android.os.Looper.loop(Looper.java:153)
02-27 13:12:21.231: E/AndroidRuntime(14687): at android.app.ActivityThread.main(ActivityThread.java:4987)
02-27 13:12:21.231: E/AndroidRuntime(14687): at java.lang.reflect.Method.invokeNative(Native Method)
02-27 13:12:21.231: E/AndroidRuntime(14687): at java.lang.reflect.Method.invoke(Method.java:511)
02-27 13:12:21.231: E/AndroidRuntime(14687): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
02-27 13:12:21.231: E/AndroidRuntime(14687): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
02-27 13:12:21.231: E/AndroidRuntime(14687): at dalvik.system.NativeStart.main(Native Method)
02-27 13:12:21.231: E/AndroidRuntime(14687): Caused by: net.sqlcipher.database.SQLiteException: file is encrypted or is not a database
02-27 13:12:21.231: E/AndroidRuntime(14687): at net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method)
02-27 13:12:21.231: E/AndroidRuntime(14687): at net.sqlcipher.database.SQLiteDatabase.setLocale(SQLiteDatabase.java:2102)
02-27 13:12:21.231: E/AndroidRuntime(14687): at net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:1968)
02-27 13:12:21.231: E/AndroidRuntime(14687): at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:901)
02-27 13:12:21.231: E/AndroidRuntime(14687): at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:944)
02-27 13:12:21.231: E/AndroidRuntime(14687): at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:107)
02-27 13:12:21.231: E/AndroidRuntime(14687): at example.SQLDemoActivity.onCreate(SQLDemoActivity.java:42)
02-27 13:12:21.231: E/AndroidRuntime(14687): at android.app.Activity.performCreate(Activity.java:5020)
02-27 13:12:21.231: E/AndroidRuntime(14687): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
02-27 13:12:21.231: E/AndroidRuntime(14687): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
02-27 13:12:21.231: E/AndroidRuntime(14687): ... 11 more
since my old db is not encrypted so what should I set password in that case
I have tried with passing null in password string and also with "" but with no luck
reported issue to https://github.com/sqlcipher/android-database-sqlcipher/issues/124
SQLCipher for Android can open an unencrypted database using ""
as the password.
Then either:
- You have a bug in your code, or
- The database is already encrypted with another password, or
- The database is corrupted.
这篇关于文件将被加密或不是一个数据库(例外net.sqlcipher.database.SQLiteException)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!