Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to get specific permissions for debugging in android?

I made an application that will, on release, write and manage a database on the internal storage, because it doesn't really need to write to the sd card

However while debugging I would like to be able to write on the sd card so I can view and edit the database for testing purposes.

Is there a way to define in AndroidManifest that I want to have the read external and write external permissions only for the debug builds but not the release builds?

thanks in advance for any help you can provide

Edit: if anyone is reading this trying to find an answer , if you are using android studio, check the accepted answer

if you are using xamarin this seems to have worked for me, edit AssemblyInfo.cs and add:

#if DEBUG
    [assembly: Application( Debuggable=true)]
    [assembly: UsesPermission("android.permission.WRITE_EXTERNAL_STORAGE")]
    [assembly: UsesPermission("android.permission.READ_EXTERNAL_STORAGE")]
#else
    [assembly: Application(Debuggable=false)]
#endif
like image 666
Cruces Avatar asked Jun 27 '16 11:06

Cruces


1 Answers

If you are using Android Studio, you can create a src/debug/AndroidManifest.xml file and include your permission in it. The contents of that manifest will be merged in with your src/main/AndroidManifest.xml file, plus manifests from any library, but only for debug builds.

like image 150
CommonsWare Avatar answered Sep 26 '22 01:09

CommonsWare