No such file or directory in Android 10 (api 29)

前端 未结 3 1109

I am working on a photo editor app in which after editing my picture I save it into my local storage. It is working fine till android 9 but not on android 10. It shows excep

3条回答
  •  春和景丽
    2021-01-13 12:33

    Here is the best I could find: https://developer.android.com/training/data-storage/app-specific#external

    Basically, you now use app-specific directories for your files. For example:

    @Nullable
    File getAppSpecificAlbumStorageDir(Context context, String albumName) {
        // Get the pictures directory that's inside the app-specific directory on
        // external storage.
        File file = new File(context.getExternalFilesDir(
                Environment.DIRECTORY_PICTURES), albumName);
        if (file == null || !file.mkdirs()) {
            Log.e(LOG_TAG, "Directory not created");
        }
        return file;
    }
    

提交回复
热议问题