I\'m creating an app for a private use only... it\'s not so important then, respect your time :P
What I want to make is an app that reads from a database and plays s
if your targetSdk is 23 than you have to check permissions like this for marshmallow and above devices
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
checkPermission();
}
else {
}
private void checkPermission() {
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED && ContextCompat.checkSelfPermission(this,
Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {//Can add more as per requirement
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.READ_EXTERNAL_STORAGE},
123);
} else {
}
}
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults)
{
switch (requestCode) {
case 123: {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//Peform your task here if any
} else {
checkPermission();
}
return;
}
}
}