-1

I am trying to copy data from DDBMS perspective -> file explorer -> data -> [my_app_package] then PULL this is working when I am running application on emulator but when I am running application on mobile nothing is shown under data folder.

I have also tried to do same thing from adb but its not working.. Is their any way to explore sqllite database created by my application without rooting my phone.

DCoder
  • 3,486
  • 7
  • 36
  • 68
  • 1
    if your Phone is rooted than i have one tool that you can edit any DB runtime – MilapTank Aug 01 '14 at 05:04
  • 1
    1. You don't have permissions to see the application data in a non rooted phone. 2. You have to create a copy of your existing database in a folder and then access it. (Vikalp Patel has given a working example below) – iZBasit Aug 01 '14 at 05:17

3 Answers3

2

One can surely retreive database .db file from Android Device programmatically. I used to put one more setting under my application named Developer Options which copy .db file into sdCard.

Following code copy .db to sdcard. Change your copied .db file name into whatever like to with backupDBPath and currentDBPath (Name which you gave to your database name).

public void dev()
    {
        try {
            File sd = Environment.getExternalStorageDirectory();
            File data = Environment.getDataDirectory();

            if (sd.canWrite()) {
                String currentDBPath = "/data/data/" + getPackageName() + "/databases/ZnameDB";
                String backupDBPath = "ZnameDB_Dev.db";
                File currentDB = new File(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();
                    Toast.makeText(SettingsActivity.this, "Database Transfered!", Toast.LENGTH_SHORT).show();
                }
            }
        } catch (Exception e) {
            Log.e(TAG, e.toString());
        }
  }

There are many application available in PlayStore with which you can view your .db file. I used aSQLiteManager android application to view .db file.

Vikalp Patel
  • 10,669
  • 6
  • 61
  • 96
0

No you can't,how ever you can use logs to fetch and see the fetched data in logcat or set some value on your textviews or use table layout too see your fetched data .However the best way is using SQLiteBrowser.You can pull the database file from your emulator or device and then save it on your hard disk and browse it in Sqlitebrowser.

nobalG
  • 4,544
  • 3
  • 34
  • 72
0

You can copy your sqlite file to sdcard programmatically. Follow this link. And view it using any Sqlite Viewer.

Community
  • 1
  • 1
Seshu Vinay
  • 13,560
  • 9
  • 60
  • 109