Issue
I'm trying to create a directory on my android emulator but I can't do it, I already have the permission on manifest write_storage, and I get no erros but mkdir() return false, I verify if external storage is writtable too and it is, it works on physical devices my code:
/// Cria uma nova pasta para colocar o backup
File direct = new File(Environment.getExternalStorageDirectory(),
"/Financas RW Backup");
try {
if (!direct.exists()) {
if(isExternalStorageWritable()&&isExternalStorageReadable()) {
if( direct.mkdir()) {
fachada.showMessage(ExportImportDB.this," Criado");
}else{
fachada.showMessage(ExportImportDB.this," Não Criado");
}
}
}
} catch (Exception e) {
fachada.showMessage(this, e.toString());
}
Solution
You have to options:
- Downgrade your
compileSdkVersion
andtargetSdkVersion
to lower version in yourbuild.gradle
- Request write permission at runtime is required on Android 6 .
I personally don't advice the first one. For more info check:
- Android 6.0 Marshmallow. Cannot write to SD Card
- Google Play services 8.1 and Android 6.0 Permissions
Hope this helps!!
Answered By - Gueorgui Obregon
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.