-2

I want to get the sqlite file from my SAMSUNG GALAXY TAB, but I dont know where is it? Please help me? Thanks a lo.

3 Answers3

0

If you mean you visited /data and found nothing in it, and you are examining an ordinary piece of Android hardware, that is expected. DDMS does not have permission to browse through /data.

However, at least if your app is compiled in debug mode, you can use the adb pull command at the console to download your file directly.

hakki
  • 6,181
  • 6
  • 62
  • 106
0

Take a look at this:

Location of sqlite database on the device

You will find it here: /data/data/Your-Application-Package-Name/databases/your-database-name

Community
  • 1
  • 1
Bobbelinio
  • 134
  • 1
  • 8
0

If your device is not rooted then you don't have access in data folder. Then you should write the database in sd card. On rooted device or emulator sqlite file is inside

/data/data/packagename/databases/

for not rooted device write file like this

private void writeToSD() throws IOException {
    File sd = Environment.getExternalStorageDirectory();

    if (sd.canWrite()) {
        String currentDBPath = DB_NAME;
        String backupDBPath = "backupname.db";
        File currentDB = new File(DB_PATH, currentDBPath);
        File backupDB = new File(sd, backupDBPath);

        if (currentDB.exists()) {
            FileChannel src = new FileInputStream(currentDB).getChannel();
            FileChannel dst = new FileOutputStream(backupDB).getChannel();
            dst.transferFrom(src, 0, src.size());
            src.close();
            dst.close();
        }
    }
}

Where DB_NAME is the name of my database and DB_PATH is defined as follows:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        DB_PATH = context.getFilesDir().getAbsolutePath().replace("files", "databases") + File.separator;
}
else {
        DB_PATH = context.getFilesDir().getPath() + context.getPackageName() + "/databases/";
}

And add the following permission in manifest:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Check this question in SO How to check database on not rooted android device

Community
  • 1
  • 1
Kaushik
  • 6,150
  • 5
  • 39
  • 54