2

My question is not duplicate to:

Environment.getExternalStorageDirectory() deprecated in API level 29 java or

Android 11 Scoped storage permissions or

Android 11 - Accessing Files in my app Android/Data folder

Answers provided in above links doesn't solve my problem as my App already targets API level 30.

Environment.getExternalStorageDirectory() is deprecated in API level 29 java.

I made a folder in External directory when API level was below 29 and had my encrypted DB placed there. I have to upgrade to API 30 as Android has forced me to do so. Now I am unable to access my folder when I moved to API 30. How can I move that folder to a place which can be easily accessible by getExternalFilesDir()?

I cannot access through getExternalFilesDir() or MediaStore as the file is not media file. I cannot use Intent actions as I can't ask app user to access the folder. Please help.

  • You should then copy it to a sub folder of getExternalFilesDir. – blackapps May 20 '21 at 15:27
  • I am unable to access my folder on external storage, hence unable to copy it. – mobile_tech May 20 '21 at 15:54
  • You did not tell that in your post. Any reason? This does not match `made a folder in External directory and had my encrypted DB placed there. ` – blackapps May 20 '21 at 15:59
  • I think I drafted the question very badly. – mobile_tech May 20 '21 at 16:04
  • @blackapps You have answered many such posts. Can you please support me in this? – mobile_tech May 20 '21 at 16:45
  • @blackapps How can I remove the duplicate question tag as my question is not duplicate or answered anywhere else. – mobile_tech May 20 '21 at 16:49
  • You should ask @Zoe ... moderator is often too soon.. – blackapps May 20 '21 at 17:11
  • But lets not wait for a moderator ... Use SAF and ACTION_OPEN_DOCUMENT_TREE to let the user select your folder. – blackapps May 20 '21 at 17:13
  • `cannot access through ...... MediaStore as the file is not media file` That does not matter. Did you try? – blackapps May 20 '21 at 17:14
  • https://developer.android.com/about/versions/11/privacy/storage – blackapps May 20 '21 at 17:18
  • @blackapps I'm not a moderator (I do moderation, but doing moderation != [being a moderator](https://meta.stackoverflow.com/questions/306596/what-is-the-difference-between-a-moderator-and-a-privileged-user#comment250268_306598)), and with 3k rep, you should already be familiar with how reopening works rather (spoiler alert: it's not assigning blame). I'm not going to reopen because "my App already targets API level 30." isn't a reason why none of them apply. The last two I used on this one explicitly target API 30 – Zoe May 20 '21 at 17:25
  • See: https://stackoverflow.com/help/duplicates https://stackoverflow.com/help/reopen-questions – Zoe May 20 '21 at 17:25
  • @Zoe, i'm not a moderator and i do no moderation. Hope to keep it that way. – blackapps May 20 '21 at 17:39
  • @blackapps oh trust me, I've noticed. – Zoe May 20 '21 at 17:49
  • @blackapps ,Zoe How to move my files from public directory to `Android/Media/com.myapp` directory in android 11 like whatsapp did without asking any permission? how to get public directory path if `getExternalStorageDirectory` is now deprecated in Q? – Bhavin Patel Jul 06 '21 at 05:46
  • @bdevloper If you haven't migrated your project to API 30 yet.. Build your app with API 29 and move your existing files from public directory(as public directory are accessible till API 29). We still have around one month after which Google will force us to publish app with Android 30 or above. – mobile_tech Jul 06 '21 at 14:38
  • i did move using kotlin Utils class here [check this out](https://stackoverflow.com/a/68265107/6333971) – Bhavin Patel Jul 07 '21 at 10:01
  • @mobile_tech - Did you find a suitable solution to this? – Erez Amir Mar 22 '22 at 09:52
  • @ErezAmir No. Only way was to build app and upload app on API-29 and migrate data to internal folder. – mobile_tech Mar 24 '22 at 09:48
  • @mobile_tech Catch22 :-) - red-tape at its best – Erez Amir Mar 27 '22 at 07:44

0 Answers0