Home » Android » What is the difference between android:uses-permission and uses-permission?

What is the difference between android:uses-permission and uses-permission?

Posted by: admin June 15, 2020 Leave a comment

Questions:

What is the difference between these two syntaxes.
android:uses-permission and uses-permission. For example:

<android:uses-permission
  android:name="android.permission.READ_EXTERNAL_STORAGE"
  android:maxSdkVersion="18" />

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

The first one was automatically added to the manifest by Android Studio when I created an activity that reads from storage. Also why did it add an android:maxSdkVersion attribute and specifically set it to 18 when I have targetSdkVersion for the project set as 21.

How to&Answers:
<uses-permission
     android:name="android.permission.WRITE_EXTERNAL_STORAGE"
     android:maxSdkVersion="18" />

Actually this permission is required for API level 18 and lower, Android 4.4 (API level 19), it’s no longer necessary for your app to request the WRITE_EXTERNAL_STORAGE permission when your app wants to write to its own application-specific directories on external storage (the directories provided by getExternalFilesDir().