如果您使用的是实际设备,除非您使用手机,否则您将无法从外部查看或访问它.
如果您使用的是模拟器,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");
}
}