I'm checking if the database in a folder of the device exists. The folder and the database exists, but is not found. The path is right, then where am I wrong?
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
之前添加“ /”。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.