1

I'm doing an application with alot of data in the database so I need to make an external database with SQlite browser and put it in my application

my problem is

I can't see data/data/database because my mobile isn't rooted and I can't root it for reasons

I'm using BlueStack emulator in Eclipse IDE

Please help

Thank you

2
  • There is no need for root to use SqLite in android apps. Commented Aug 29, 2015 at 10:50
  • With Context.getExternalFilesDir() you can determine the proper path to put the database. You application will need permission READ_EXTERNAL_STORAGE to read the data base and WRITE_EXTERNAL_STORAGE it. Commented Aug 29, 2015 at 10:55

2 Answers 2

2

you can create your database and put it in your assets directory and on first use copy to data directory.

try {

    String destPath = "/data/data/" + getPackageName()
            + "/databases/YOURDbFileName";

    File f = new File(destPath);
    if(!f.exists()){
    Log.v(TAG,"File Not Exist");
    InputStream in = getAssets().open("YOURDbFileName");
    OutputStream out = new FileOutputStream(destPath);

    byte[] buffer = new byte[1024];
    int length;
    while ((length = in.read(buffer)) > 0) {
        out.write(buffer, 0, length);
    }
    in.close();
    out.close();
    }

} catch (FileNotFoundException e) {
    e.printStackTrace();
} catch (IOException e) {
    Log.v("TAG","ioexeption");
    e.printStackTrace();
}
Sign up to request clarification or add additional context in comments.

Comments

0

You need to copy the external database into a folder that is accessible by the phone. So that you can manipulate the database from there.

new location must be: "/data/data/your.app.package/databases/yourdatabasename"

1 Comment

The usual extensions are .db or .sqlite.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.