如何检查的外部存储空间的可用性?可用性、存储空间

2023-09-04 11:11:40 作者:旅友

你如何检查SD卡已满或不那么你的应用程序可以决定是否可以继续做自己的工作,即写入外部存储或通知存储已经用尽空间的用户。

How do you check if the SD card is full or not so that your application can decide if it can continue to do its job i.e. write to external storage or notify the user that storage has run out of space.

推荐答案

使用体statfs ,并通过外部存储目录的路径构造,并且可以调用功能,为 getAvailableBlocks() getBlockSize()体statfs 对象。

Use StatFs and pass the path of the external storage directory to the constructor and you can call functions such as getAvailableBlocks() and getBlockSize() on the StatFs object.