在rooted设备中读取其他应用程序数据库

时间:2015-03-29 12:18:17

标签: android sqlite

我可以通过将他们的数据库复制到sdcard文件夹来读取其他应用程序数据库,但我想读取它们而不复制到sdcard文件夹但是你可以看到我收到了错误

如果有任何方法可以通过将数据库复制到SD卡来读取其他应用数据库,请告诉我

String [] cmd1 = {"su", "-c", "chmod", "777", "/data/data/com.viber.voip/databases/viber_messages"};

try
{
    Process process = new ProcessBuilder(cmd1).start();
    process.waitFor();

} catch (Exception e)
{
    e.printStackTrace();
}

SQLiteDatabase database = SQLiteDatabase.openDatabase("/data/data/com.viber.voip/databases/viber_messages", null, SQLiteDatabase.OPEN_READONLY);

Cursor cursor = database.rawQuery("SELECT * FROM messages", null);

这是我的错误

03-29 16:10:36.181    2255-2255/com.example.john.viber E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.john.viber/com.example.john.viber.MainActivity}: android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 3850): , while compiling: SELECT * FROM messages
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2247)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2297)
            at android.app.ActivityThread.access$700(ActivityThread.java:152)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1282)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5328)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 3850): , while compiling: SELECT * FROM messages
            at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
            at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1090)
            at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:663)
            at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
            at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
            at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
            at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
            at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1420)
            at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1359)
            at com.example.john.viber.MainActivity.onCreate(MainActivity.java:60)
            at android.app.Activity.performCreate(Activity.java:5250)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2297)
            at android.app.ActivityThread.access$700(ActivityThread.java:152)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1282)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5328)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
            at dalvik.system.NativeStart.main(Native Method)

0 个答案:

没有答案