Environment.getExternalStorageDirectory() deprecated in API level 29 java

前端 未结 6 975
梦毁少年i
梦毁少年i 2020-11-22 13:08

Working on android Java, recently updated SDK to API level 29 now there is a warning shown which states that

Environment.getExternalStorageDirectory() i

6条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 13:46

    For Android Q, you can add android:requestLegacyExternalStorage="true" to your element in the manifest. This opts you into the legacy storage model, and your existing external storage code will work.

    
    
      
        ...
      
    
    

    Technically, you only need this once you update your targetSdkVersion to 29. Apps with lower targetSdkVersion values default to opting into legacy storage and would need android:requestLegacyExternalStorage="false" to opt out.

提交回复
热议问题