android 数据库资源管理器,android – SQLite数据库没有显示在文件资源管理器中

如果您使用的是实际设备,除非您使用手机,否则您将无法从外部查看或访问它.

如果您使用的是模拟器,DDMS视图将允许您导航到它并从那里拉出它.

或者,您可能会遇到创建数据库的问题.没有看到你的代码,我们无法分辨.

编辑

如果要从真实设备中获取文件,则需要实现一种方法将其从数据目录复制到您有权访问的位置(例如SD卡).这样可以解决问题:

public void backup() {

try {

File sdcard = Environment.getExternalStorageDirectory();

File outputFile = new File(sdcard,

"YourDB.bak");

if (!outputFile.exists())

outputFile.createNewFile();

File data = Environment.getDataDirectory();

File inputFile = new File(data, "data/your.package.name/databases/yourDB");

InputStream input = new FileInputStream(inputFile);

OutputStream output = new FileOutputStream(outputFile);

byte[] buffer = new byte[1024];

int length;

while ((length = input.read(buffer)) > 0) {

output.write(buffer, 0, length);

}

output.flush();

output.close();

input.close();

} catch (IOException e) {

e.printStackTrace();

throw new Error("Copying Failed");

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值