Test programmatically if in Android 10+ the legacy external storage access is disabled

怎甘沉沦 提交于 2019-12-05 04:32:57

You can use these two methods from android.os.Environment:

  • isExternalStorageLegacy(File path)

    Returns whether the shared/external storage media at the given path is a legacy view that includes files not owned by the app.

  • isExternalStorageLegacy()

    Returns whether the primary shared/external storage media is a legacy view that includes files not owned by the app.

This value may be different from the value requested by requestLegacyExternalStorage in the app's manifest, since an app may inherit its legacy state based on when it was first installed.

Non-legacy apps can continue to discover and read media belonging to other apps via MediaStore.

In case you discover that you have access to legacy storage, personally I think it's better to just migrate data over to scoped storage and use it instead since legacy storage may stop working without warning.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!