我正在检查设备文件夹中的数据库是否存在。文件夹和数据库存在,但未找到。路是对的,那我哪里错了?
private void checkDBexists() {
File internal = Environment.getExternalStorageDirectory();
File myFile = new File(internal.getAbsoluteFile() + "MyFolder/database.db");
if (myFile.exists()) {
importaDB();
} else {
Toast toast = Toast.makeText(getActivity().getApplicationContext(), "not work", Toast.LENGTH_SHORT);
toast.show();
}
}
最佳答案
File myFile = new File(internal.getAbsoluteFile()+"/MyFolder/database.db");
在 MyFolder
前添加“/”。
关于Android检查文件是否存在()不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30492059/