Search code examples
androidandroid-download-manager

No permission to write on android emulator


I have been trying to download a file from a url. I have set the permissions in my android manifest file like so,

  <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

I am using a library called Adavnced WebView to handle downloads:

AdvancedWebView.handleDownload(view.getContext(),"https://static1.squarespace.com/static/57752cbed1758e541bdeef6b/t/58d91311ff7c50b172946ee5/1490621221735/PreKGuide_2017_English_032417+%281%29.pdf" , "abc.txt");

I get an error when I try to download. It clearly says that the app doesn't have permission to write to storage path. How can I set permission to write? What am I missing here? Please help.

java.lang.SecurityException: No permission to write to /storage/emulated/0/Download/abc.txt: Neither user 10147 nor current process has android.permission.WRITE_EXTERNAL_STORAGE.

Solution

  • You need the runtime permission, check the documentation.