-1

My app targetting API 30. My app is integrated with com.github.barteksc:android-pdf-viewer:2.8.2 which uses InputStream & OutputStream to download & display file in pdfview. Using Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) to store downloaded files. I have included these permission in my AndroidManifest.xml

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

if I remove MANAGE_EXTERNAL_STORAGE, my pdf doesn't gets loaded in android 10 & above. If I include MANAGE_EXTERNAL_STORAGE permission google play rejecting my app.enter image description here How to fix this issue. I'm stuck here no where I cannot find proper troubleshooting for this issue. Please help me.

  • https://stackoverflow.com/a/68816379/8133524 check this – Ramesh Jul 05 '22 at 13:54
  • If i downgrade to API 29, I wont be able to upload app see minimum requirement. https://developer.android.com/google/play/requirements/target-sdk – abhilash kaveriappa Jul 05 '22 at 13:58
  • You will not have access to `DIRECTORY_DOCUMENTS`, except for documents that your app put there. Use `ACTION_OPEN_DOCUMENT` / `ActivityResultContracts.OpenDocument` and let the user choose the document. You can then get streams from `ContentResolver`. – CommonsWare Jul 05 '22 at 13:59
  • Can you share similar examples to Download & get file URL using ContentResolver. – abhilash kaveriappa Jul 05 '22 at 14:31

1 Answers1

0

I tried not to use DIRECTORY_DOCUMENTS but instead used scoped storage which requires only

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

Replaced this line

Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS)

with this

 File file = new File(getExternalFilesDir(filepath), filename);

App approved by Google Play also working fine.