2
我正在檢查設備文件夾中的數據庫是否存在。該文件夾和數據庫存在,但未找到。路徑是正確的,那麼我錯在哪裏?Android檢查文件是否存在()不起作用
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();
}
}
是的,謝謝! – user2847219
請標記爲正確的答案。 – Divers