How can I check how much free space an SD card mounted on an Android device has?

前端 未结 5 2113
轻奢々
轻奢々 2020-11-29 02:04

How can I programmatically check how much free space an SD card mounted on an Android device has?

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 02:31

    Here's a simpler way, that is usable since API level 9:

    Environment.getExternalStorageDirectory().getUsableSpace();
    

    http://developer.android.com/reference/java/io/File.html#getUsableSpace()

提交回复
热议问题