PropK
PropK

Reputation: 687

Not able to access sqlite database Android

Ive created an app that stores user login information into an sqlite database. However when i try to access it using Root Explorer i get an error.

An error occurred while opening the database. disk i/o error (code 3850):, while compiling: Select * from sqlite_master where type in('table','view') order by name.

The app works fine, and it is storing the log in information as required. However i cant access it on the root explorer?

Any suggestions?

Upvotes: 0

Views: 957

Answers (3)

Pek Ifly
Pek Ifly

Reputation: 159

Just give permissions to all users to the file [YOUR_DB].db-journal

For me it worked.

Upvotes: 0

dipali
dipali

Reputation: 11188

please call this function:

public static void copyDataBase(Context mActivity) throws IOException {
        InputStream myInput = new FileInputStream(new File("/data/data/"
                + mActivity.getPackageName() + "/databases/" + "yourdb.sqlite"));
        File files = new File("/sdcard/files/");
        files.mkdirs();
        String outFileName = "/sdcard/files/your.sqlite";
        OutputStream myOutput = new FileOutputStream(outFileName);
        byte[] buffer = new byte[1024];
        int bufferLength;
        while ((bufferLength = myInput.read(buffer)) > 0) {
            myOutput.write(buffer, 0, bufferLength);
        }
        myOutput.flush();
        myOutput.close();
        myInput.close();
    }

your database is copied /sdcard/files/your.sqlite this path.

Upvotes: 1

Hao Xiao
Hao Xiao

Reputation: 83

You could add a button in your app to view the database information or write the database information to a file in external storage.

Otherwise, maybe you need to root your device to access the database.

Upvotes: 0

Related Questions