Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment.getExternalStorageDirectory is deprecaterd and needs to be replaced with Storage Access Framework #30

Open
maniksejwal opened this issue Nov 14, 2019 · 2 comments
Labels
good first issue Good for newcomers

Comments

@maniksejwal
Copy link
Collaborator

Environment.getExternalStorageDirectory has been deprecated in Android Q. It should stop working in Android R. This is done to ensure privacy.

The new alternative for File handling is the Storage Access Framework.

https://github.com/baldapps/Flipper is a library that helps in keeping the old behaviour and can be tried.

@maniksejwal maniksejwal added the good first issue Good for newcomers label Nov 14, 2019
@maniksejwal
Copy link
Collaborator Author

@shetyeanuja can you mention the resolving commit in this thread

@shetyeanuja
Copy link
Contributor

Instead of Helper.APP_FOLDER directory for saving the file, we can use getFilesDir()

//After API 23 permission request is asked at runtime
int EXTERNAL_STORAGE_PERMISSION_CODE = 23;
//Requesting Permission to access External Storage
        ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
                EXTERNAL_STORAGE_PERMISSION_CODE);
//It creates an app-specific directory, hidden from users and deleted with the app
        File folder = getActivity().getFilesDir();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants