Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sqlite android设备监视器API 19中的数据文件夹未打开_Sqlite - Fatal编程技术网

Sqlite android设备监视器API 19中的数据文件夹未打开

Sqlite android设备监视器API 19中的数据文件夹未打开,sqlite,Sqlite,我正在使用usb调试(SM-G335h版本4.4.2 API 19),我想从android studio导出数据库,但数据文件夹无法展开。有人知道怎么解决这个问题吗? 我曾尝试使用adb根目录对我的手机进行根目录操作,但没有成功。解决方法是将数据库文件从应用程序中复制到可访问的位置 例如,这样一个位置可以是downloads文件夹,它可以通过以下方式确定/访问:- File yourdir = new File(Environment.getExternalStoragePublicDirect

我正在使用usb调试(SM-G335h版本4.4.2 API 19),我想从android studio导出数据库,但数据文件夹无法展开。有人知道怎么解决这个问题吗?
我曾尝试使用adb根目录对我的手机进行根目录操作,但没有成功。

解决方法是将数据库文件从应用程序中复制到可访问的位置

例如,这样一个位置可以是downloads文件夹,它可以通过以下方式确定/访问:-

File yourdir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath());
  • 注意,您需要设置适当的权限
您可以使用以下方法获取数据库位置:-

Context.getDatabasePath("your_database_name");
e、 g.一个非常基本/最低限度的例子可以是:-

    File from = new File(a_suitable_context.getDatabasePath("your_database_name").getPath());
    File to = new File(a_suitable_context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).getPath() + File.separator + "your_db_savename");
    byte[] bffr = new byte[1024];
    FileInputStream fsfrom;
    FileOutputStream fsto;
    try {
        fsfrom = new FileInputStream(from);
        fsto = new FileOutputStream(to);
        while(fsfrom.read(bffr) > 0) {
            fsto.write(bffr);
        }
        fsto.flush();
        fsfrom.close();
        fsto.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
然后,您可以从AS的设备资源管理器访问此文件。e、 g:-

  • 注意:这使用下载文件夹中的子目录

  • 注意
    合适的\u上下文
    您的\u数据库名称
    您的\u db\u保存名称
    都是您将提供的合适值(后者都可以是数据库名称)

  • 如果dabase相当大,则您可能希望增加bfrr大小
您也可以从这里使用解决方案