-1

i use asyncTask to download apk file in to:

Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)

now, this need dangerous permission or not? and where is granted location for write file without dangerous permission need? thanks

Farzad
  • 1,975
  • 1
  • 25
  • 47

1 Answers1

1

According to the Android Documentation you can use normal permissions:

Normal permissions cover areas where your app needs to access data or resources outside the app's sandbox, but where there's very little risk to the user's privacy or the operation of other apps. For example, permission to set the time zone is a normal permission. If an app declares that it needs a normal permission, the system automatically grants the permission to the app. For a full listing of the current normal permissions, see Normal permissions.

More specifically, you need to use Write Permission in order to write on Internal/External storage. You can add the following on your manifest file to get write permissions on the Downloads folder:

<manifest ...>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    ...
</manifest>

I also recommend reading the official documentation for more info.

Abandoned Cart
  • 4,512
  • 1
  • 34
  • 41
  • how to get path `INTERNAL_STORAGE`? getExternalStoragePublicDirectory is external.! – Farzad Jul 16 '17 at 18:58
  • By using the following method: getFilesDir() Returns a File representing an internal directory for your app. More info here https://developer.android.com/training/basics/data-storage/files.html#InternalVsExternalStorage – Juan Torres Jul 17 '17 at 05:35
  • `android.permission.WRITE_INTERNAL_STORAGE` doesn't exist in any current or previous Android API. @JuanTorres I suggest taking a minute to review your own link. – Abandoned Cart Dec 16 '21 at 14:13