gpt4 book ai didi

android - SQLiteDatabase 使用路径打开特定数据库

转载 作者:行者123 更新时间:2023-11-30 03:29:47 25 4
gpt4 key购买 nike

我想打开一个包含所有短信和彩信的数据库。我想这样做是因为我需要进行原始查询,所以我需要让它工作。我正在尝试这样做:

    try{
SQLiteDatabase sqLiteDatabase = SQLiteDatabase.openDatabase("/data/data/com.android.providers/telephony/databases/mmssms.db", null, SQLiteDatabase.OPEN_READWRITE);
}catch(Exception e){
e.printStackTrace();
}

我得到这样的错误:

07-15 10:13:11.784: E/SQLiteLog(13014): (14) cannot open file at line 30176 of [00bb9c9ce4]
07-15 10:13:11.784: E/SQLiteLog(13014): (14) os_unix.c:30176: (2) open(/data/data/com.android.providers/telephony/databases/mmssms.db) -
07-15 10:13:12.084: E/SQLiteDatabase(13014): Failed to open database '/data/data/com.android.providers/telephony/databases/mmssms.db'.
07-15 10:13:12.084: E/SQLiteDatabase(13014): android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:804)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:789)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:669)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at ppm.messenger.androidppmmessenger.MainActivity.onCreate(MainActivity.java:62)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.app.Activity.performCreate(Activity.java:5104)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.os.Handler.dispatchMessage(Handler.java:99)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.os.Looper.loop(Looper.java:137)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at java.lang.reflect.Method.invokeNative(Native Method)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at java.lang.reflect.Method.invoke(Method.java:511)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-15 10:13:12.084: E/SQLiteDatabase(13014): at dalvik.system.NativeStart.main(Native Method)
07-15 10:13:12.094: W/System.err(13014): android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
07-15 10:13:12.094: W/System.err(13014): at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
07-15 10:13:12.104: W/System.err(13014): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209)
07-15 10:13:12.116: W/System.err(13014): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
07-15 10:13:12.124: W/System.err(13014): at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
07-15 10:13:12.134: W/System.err(13014): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
07-15 10:13:12.134: W/System.err(13014): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
07-15 10:13:12.147: W/System.err(13014): at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:804)
07-15 10:13:12.147: W/System.err(13014): at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:789)
07-15 10:13:12.154: W/System.err(13014): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
07-15 10:13:12.166: W/System.err(13014): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:669)
07-15 10:13:12.174: W/System.err(13014): at ppm.messenger.androidppmmessenger.MainActivity.onCreate(MainActivity.java:62)
07-15 10:13:12.174: W/System.err(13014): at android.app.Activity.performCreate(Activity.java:5104)
07-15 10:13:12.185: W/System.err(13014): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-15 10:13:12.194: W/System.err(13014): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
07-15 10:13:12.194: W/System.err(13014): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-15 10:13:12.204: W/System.err(13014): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-15 10:13:12.214: W/System.err(13014): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-15 10:13:12.224: W/System.err(13014): at android.os.Handler.dispatchMessage(Handler.java:99)
07-15 10:13:12.234: W/System.err(13014): at android.os.Looper.loop(Looper.java:137)
07-15 10:13:12.234: W/System.err(13014): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-15 10:13:12.244: W/System.err(13014): at java.lang.reflect.Method.invokeNative(Native Method)
07-15 10:13:12.244: W/System.err(13014): at java.lang.reflect.Method.invoke(Method.java:511)
07-15 10:13:12.254: W/System.err(13014): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-15 10:13:12.284: W/System.err(13014): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-15 10:13:12.294: W/System.err(13014): at dalvik.system.NativeStart.main(Native Method)

我想知道如何正确打开这个数据库。

最佳答案

您的问题并不新鲜。看起来您需要了解一些信息,了解您的数据库服务器的连接是如何工作的。

答案已经给出HERE

关于android - SQLiteDatabase 使用路径打开特定数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17651910/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com