3

Suppose I have a Notepad-like app, where you can create and save text documents.

I want my users to be able to access those files (so that they can copy them to a computer, for example).

Before API 29, getExternalStorageDirectory() was a good choice - the directory was created in the root of sdcard and easily accessible. However, since API 29 it is deprecated. So now I have to use getExternalFilesDir(null) directory.

The problem is that that directory's path is something like Android/data/your_package_name/files, which is very inconvenient for the users. Many of them can't find it. So, which method should I use?

Lev Leontev
  • 2,538
  • 2
  • 19
  • 31
  • Check the alternatives in the deprecated note here: https://developer.android.com/reference/android/os/Environment#getExternalStorageDirectory() – Saurabh Thorat Nov 25 '19 at 14:37
  • https://stackoverflow.com/questions/57116335/environment-getexternalstoragedirectory-deprecated-in-api-level-29-java - these answers might be helpful. – Artem Nov 25 '19 at 14:55
  • You can use a classic file-picker module which you let start in the mentioned directory. – blackapps Nov 25 '19 at 19:39

1 Answers1

0

Use getExternalFilesDir(), getExternalCacheDir(), or getExternalMediaDir() (methods on Context) instead of Environment.getExternalStorageDirectory().

Shivam Yadav
  • 958
  • 11
  • 23