0

Im following a simple tutorial on SQLite in android. I tried the code in my mobile phone and tablet, and there is no crash. The main layout just stays there as it should do.(empty activity). And the app is supposed to create the database. But when i check the android device manager file explorer I can't see "data/data" folder. Instead I saw my project folder in a folder named "mnt". I dont know why but the package name was com.something.dhbelper in android studio and it was saved in that mnt folder as com.something.dbhelper1 (number added to the end) When I disconnect my phone from PC and TAP my files icon on the phone, I see android/data/data folders and I cant see neither "mnt" folder nor my application.But there is shortcut of the app on my phone and I can run it by tapping.

How can I see that folder using Android Device Manager's File Explorer?

What do you suggest? Is there a way to search for ,lets say student.db file? Thanks in advance.

Engin Deniz
  • 1
  • 1
  • 3

3 Answers3

1

Can't comment so I'll answer here.

Try it in an Emulator. You can't access those folders on a device unless it is rooted.

You can use the adb pull shell command to copy the db file onto your local machine.

http://adbshell.com/commands/adb-pull

BennyLava
  • 91
  • 7
1

Stetho from Facebook allows you to view the on device database (as well as other things) using Chrome developer tools. It's very easy to set up and use. http://facebook.github.io/stetho/

Ivan Wooll
  • 4,145
  • 3
  • 23
  • 34
0

First of all, you cannot see inside of /data/data/ as it is not browsable unless you have root permission. But, you can access it by code.

the mnt, abbreviation of mount, is appeared as the Android Studio gives right to browse the path including your db file for development purpose.

Check out below code to copy only accessible but not browsable database file to somewhere you wanted. Note that only the app which creates the database has privilege to run this code.

File f=new File("/data/data/your.app.package/databases/your_db"); // case-sensitive!
FileInputStream fis=null;
FileOutputStream fos=null;

try
{
  fis=new FileInputStream(f);
  fos=new FileOutputStream("/mnt/sdcard/db_dump.db"); // target location
  while(true)
  {
    int i=fis.read();
    if(i!=-1)
    {fos.write(i);}
    else
    {break;}
  }
  fos.flush();
  Toast.makeText(this, "DB dump OK", Toast.LENGTH_LONG).show();
}
catch(Exception e)
{
  e.printStackTrace();
  Toast.makeText(this, "DB dump ERROR", Toast.LENGTH_LONG).show();
}
finally
{
  try
  {
    fos.close();
    fis.close();
  }
  catch(IOException ioe)
  {}
}

Note that this code is copied from: https://stackoverflow.com/a/13154281/361100

Community
  • 1
  • 1
Youngjae
  • 24,352
  • 18
  • 113
  • 198