From 3863979df8f0c9ae0eac22360f7b1d836a296d32 Mon Sep 17 00:00:00 2001 From: Nandana Dutt Date: Thu, 27 May 2021 13:06:43 +0100 Subject: [PATCH] Fix storage directory API docs Android 10 did not support file path operations for apps in scoped storage. But Android 11 and above do support file path operations for such apps. Fix docs for getExternalStorageDirectory() and getExternalStoragePublicDirectory() to reflect the current level of support. BUG: 153562415 Test: m docs Change-Id: I8bc2a4aa266dbbcc391b415e6209ed6e5d56fe97 --- core/java/android/os/Environment.java | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/core/java/android/os/Environment.java b/core/java/android/os/Environment.java index 21bf8b8c30e4f..2ed0bad69460d 100644 --- a/core/java/android/os/Environment.java +++ b/core/java/android/os/Environment.java @@ -698,14 +698,9 @@ public class Environment { * * @see #getExternalStorageState() * @see #isExternalStorageRemovable() - * @deprecated To improve user privacy, direct access to shared/external - * storage devices is deprecated. When an app targets - * {@link android.os.Build.VERSION_CODES#Q}, the path returned - * from this method is no longer directly accessible to apps. - * Apps can continue to access content stored on shared/external - * storage by migrating to alternatives such as - * {@link Context#getExternalFilesDir(String)}, - * {@link MediaStore}, or {@link Intent#ACTION_OPEN_DOCUMENT}. + * @deprecated Alternatives such as {@link Context#getExternalFilesDir(String)}, + * {@link MediaStore}, or {@link Intent#ACTION_OPEN_DOCUMENT} offer better + * performance. */ @Deprecated public static File getExternalStorageDirectory() { @@ -1014,14 +1009,9 @@ public class Environment { * @return Returns the File path for the directory. Note that this directory * may not yet exist, so you must make sure it exists before using * it such as with {@link File#mkdirs File.mkdirs()}. - * @deprecated To improve user privacy, direct access to shared/external - * storage devices is deprecated. When an app targets - * {@link android.os.Build.VERSION_CODES#Q}, the path returned - * from this method is no longer directly accessible to apps. - * Apps can continue to access content stored on shared/external - * storage by migrating to alternatives such as - * {@link Context#getExternalFilesDir(String)}, - * {@link MediaStore}, or {@link Intent#ACTION_OPEN_DOCUMENT}. + * @deprecated Alternatives such as {@link Context#getExternalFilesDir(String)}, + * {@link MediaStore}, or {@link Intent#ACTION_OPEN_DOCUMENT} offer better + * performance. */ @Deprecated public static File getExternalStoragePublicDirectory(String type) {