根存储或外部存储Android中存在文件

时间:2019-04-30 08:33:25

标签: android android-external-storage android-storage

我像下面一样保存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;
    }

问题:

如何检查存储了哪些filestrue是这样吗?

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...
    }

0 个答案:

没有答案