Существующий файл в корневом хранилище или внешнем хранилище Android - PullRequest
0 голосов
/ 30 апреля 2019

Я экономлю files, как показано ниже:

public boolean isExternalStorageAvailabled(Context context) {
    String state = Environment.getExternalStorageState();
    return state.equals(Environment.MEDIA_MOUNTED) && context.getExternalFilesDir(null) != null;
}

И:

    Utils utils = new Utils();
    if (utils.isExternalStorageAvailabled(context)) {
        return Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "Android" + File.separator + "data" + File.separator + context.getPackageName() + File.separator + "files";
    } else {
        return context.getApplicationContext().getFilesDir().getAbsolutePath() + DOWNLOADS_DIR;
    }

Проблема:

Как проверитькакие files хранятся?это так true?

File path = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "Android" + File.separator + "data" + File.separator + context.getPackageName() + File.separator + "files" + File.separator + (BATCH + fileName) + File.separator + "MMM" + File.separator + fileName);
File pathRoot = new File(context.getApplicationContext().getFilesDir().getAbsolutePath() + "/downloads/" +(BATCH + fileName) + "/MMM/" + fileName);
if (!path.exists() || !pathRoot.exists()) {
       some code...
    }
...