Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Android version greater than 23 #7

Open
pgAlves2 opened this issue Jan 12, 2017 · 1 comment
Open

Android version greater than 23 #7

pgAlves2 opened this issue Jan 12, 2017 · 1 comment

Comments

@pgAlves2
Copy link

pgAlves2 commented Jan 12, 2017

If android version is greater than 23(6.0) is necessary order the WRITE_EXTERNAL_STORAGE permission for create files, cuz this permission among others must be requested in run time (only version >=23).

Example method:

public boolean isStoragePermissionGranted() { if (Build.VERSION.SDK_INT >= 23) { if (checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { return true; } else { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1); return false; } } else { return true; } }

Callback :

@Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); if(grantResults[0]== PackageManager.PERMISSION_GRANTED){ //do something } }

ty for your code!

@JosephM3388
Copy link

So you are saying we need to ask for the WRITE_EXTERNAL_STORAGE permission if we are using marshmallow?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants