Search Unity

How to request for permission to read storage folders using manifest.xml?

Discussion in 'Android' started by rawegames, Jan 22, 2017.

  1. rawegames

    rawegames

    Joined:
    Aug 1, 2016
    Posts:
    91
    Original post:
    https://forum.unity3d.com/threads/u...hen-trying-to-access-photos-directory.452403/

    I have 0 experience on manifest.
    I have close to 0 knowledge on xml format.
    My project currently does not have a Assets/Android/Plugins/manifest.xml file.
    I am clueless on where to begin.

    I've found the following manifest file regarding permissions, with no further documentation.
    https://developer.android.com/samples/PermissionRequest/AndroidManifest.html

    I was also unable to find any non-paid tutorials that target this specific question:
    How to request for permission to access directory using manifest.xml?

    I only need to retrieve the files in the directory, I don't need to write to it.

    Thanks,
    RAWEGames
     
    Last edited: Jan 22, 2017
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
  3. rawegames

    rawegames

    Joined:
    Aug 1, 2016
    Posts:
    91
    I need the permission to retrieve the files in a directory.

    Right now, I get an UnauthorizedAccessException when I run the following code:
    Directory.GetFiles("/storage/sdcard0/Pictures");
     
  4. rawegames

    rawegames

    Joined:
    Aug 1, 2016
    Posts:
    91
    I've read up this:
    https://developer.android.com/guide/topics/manifest/manifest-intro.html#perms

    I'm rather confused.

    Here's a piece of code I found:
    Code (csharp):
    1.  
    2. <manifest . . . >
    3.     <permissionandroid:name="com.example.project.DEBIT_ACCT" . . . />
    4.     <uses-permissionandroid:name="com.example.project.DEBIT_ACCT"/>
    5.     . . .
    6.     <application . . .>
    7.         <activityandroid:name="com.example.project.FreneticActivity"
    8.                   android:permission="com.example.project.DEBIT_ACCT"
    9.                   . . . >
    10.             . . .
    11.         </activity>
    12.     </application></manifest>
    13.  
    I've found "android.permission.READ_EXTERNAL_STORAGE" permission, which I supposes should allow me to read external storage.
    I replaced all "com.example.project.DEBIT_ACCT" with "android.permission.READ_EXTERNAL_STORAGE", removed all " . . . ", because I don't know what to put there, and got this:

    Code (csharp):
    1.  
    2. <manifest>
    3.     <permissionandroid:name="android.permission.READ_EXTERNAL_STORAGE"/>
    4.     <uses-permissionandroid:name="android.permission.READ_EXTERNAL_STORAGE"/>
    5.     <application>
    6.         <activityandroid:name="com.MyCompanyName.MyProjectName.???"
    7.                   android:permission="android.permission.READ_EXTERNAL_STORAGE">
    8.         </activity>
    9.     </application>
    10. </manifest>
    11.  
    Am I using manifest correctly?

    Will using READ_EXTERNAL_STORAGE allow me to read every single folder in the external storage?
     
    Last edited: Jan 31, 2017
  5. rawegames

    rawegames

    Joined:
    Aug 1, 2016
    Posts:
    91
    1 month bump.
     
    Last edited: May 30, 2017
  6. rawegames

    rawegames

    Joined:
    Aug 1, 2016
    Posts:
    91