How to save files in External Storage Public Directory DOCUMENTS on Android 4.1.2

后端 未结 2 497
天命终不由人
天命终不由人 2021-02-07 12:13

i want to save a file on my Android 4.1.2 smartphone in the documents directory.

This code snippet:

File file = new File(Environment.getExternalStorageP         


        
2条回答
  •  感情败类
    2021-02-07 12:21

    The folder is present in older Versions (from Api 1) of Android but the field DIRECTORY_DOCUMENTS is available first in Version 4.4 (Api 19 - Kitkat).

    Solution for me was to use Environment.getExternalStorageDirectory() + "/Documents" instead DIRECTORY_DOCUMENTS for older Android Versions.

提交回复
热议问题