7

I have a SQLite Database on my Android Device (My own App). Now i want to see the SQLite Database on my Computer.

Is there any solution ( easy way ) to get the Database without root rights and without a SD-Card on my Computer?

I tried to google it but i can't find any solution for this problem....

Edit: I'm using not the Emulator ( need the Camera on my Device).

FunkyMan
  • 309
  • 5
  • 13
  • In my opinion there is no way for a non rooted device to get sqlite database from. – Vijay Mar 31 '16 at 07:30
  • The easiest way is through Terminal, the complete guide in this link . answer by dheeraj bhaskar. http://stackoverflow.com/questions/18370219/how-to-use-adb-in-android-studio-to-view-an-sqlite-db – HourGlass Mar 31 '16 at 07:40

3 Answers3

6

if phone is not rooted you cant access directly your DB, but you can copy it to download folder, then, copy to PC

public static void copyAppDbToDownloadFolder(Activity ctx) throws IOException {
    File backupDB = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
            "databse_name.db"); // for example "my_data_backup.db"
    File currentDB = getApplicationContext().getDatabasePath("databasename.db");
    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();
    }
}
khyper
  • 124
  • 1
  • 6
4

This method worked for my unrooted device.

# check if your device connected
adb devices

adb shell

run-as  your.package.name

chmod 777 databases/your.database.name

exit

cp /data/data/your.package.name/your.database.name /mnt/sdcard/

exit

adb pull /mnt/sdcard/your.database.name
Afriza N. Arief
  • 7,696
  • 5
  • 47
  • 74
crashOveride
  • 839
  • 6
  • 12
1

If you are saving Sqlite DB in default location , you can find the same in path like following

/data/data/com.dev.myapplication/databases/mydb.db

You can find the same using Android Device Monitor, through which you can navigate to both internal and external memory.

Once you find the database file, extract the same and save in desktop after connecting through USB cable. You can use option "Pull a file from device"

enter image description here

Once you have extracted file to desktop, use any tools similar to Mozilla Firefox SQLite viewer to view database.

Sreehari
  • 5,621
  • 2
  • 25
  • 59