How can I see the contents of a sqlite db of my app in a real device?

后端 未结 5 568
迷失自我
迷失自我 2021-01-06 04:39

I want to see the contents of my database created in my app in the device I deploied it. I can use sqlite commands in shell and see in emulator but not in a real device.

5条回答
  •  攒了一身酷
    2021-01-06 05:15

    Try this function as

    copyFile(new File("data/data//database"),new File("mnt/sdcard/....")).

    public void copyFile(File filesrc, File filedst)
     {
      try
     {
      FileInputStream localFileInputStream = new FileInputStream(filesrc);
      FileOutputStream localFileOutputStream = new FileOutputStream(filedst);
      byte[] arrayOfByte = new byte[1024];
      while (true)
      {
        int i = localFileInputStream.read(arrayOfByte);
        if (i == -1)
        {
          localFileOutputStream.close();
          localFileInputStream.close();
          break;
        }
        localFileOutputStream.write(arrayOfByte, 0, i);
      }
    }
    catch (Exception localException)
    {
      Log.d("XXX", "ExceptioncopyFile:" + localException.getMessage(), localException);
    }
    

    }

提交回复
热议问题