What is the SQLITE directory?

Asked

Viewed 887 times

0

Where’s the SQLITE database I created in the android studio IDE? I searched and didn’t find it, and I couldn’t find it in the phone itself .

  • It usually stays in the folder /data/data/nome_do_pacote/databases/. But to access from outside the app you need to have root. If you want you can even create something in your app that exports to a folder on sdcard or in the ExternalStorage and then access through adb or by the same usb connection.

1 answer

1

For that I made:

File f=new File("/data/data/seu.app.package/databases/seu_db.db3");
FileInputStream fis=null;
FileOutputStream fos=null;

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

Give the permission

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

It’s not brilliant, but it works

  • 1

    It scared the way you use exceptions. http://answall.com/a/21939/101

  • lol. What has been said depends on the application of Try catch

  • In case you are applying completely wrong.

  • bigown, before saying that you are wrong, you should, as a rule, present an answer by means of a code or a valid explanation.

  • Don’t invent rules that don’t exist. I explained in several answers that I showed you, did you read them all? If you’re not satisfied then ask a specific question about this and I’ll answer.

  • Bigown, I humbly apologize for the way in which I expressed my inquiry. I did not realize that you were the author of the reference. Thank you for your contribution on pt.stackoverflow.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.