Android get free size of internal/external memory

前端 未结 13 1153
眼角桃花
眼角桃花 2020-11-22 15:20

I want to get the size of free memory on internal/external storage of my device programmatically. I\'m using this piece of code :

StatFs stat = new StatFs(En         


        
13条回答
  •  迷失自我
    2020-11-22 15:27

    Since API 9 you can do:

    long freeBytesInternal = new File(ctx.getFilesDir().getAbsoluteFile().toString()).getFreeSpace();
    long freeBytesExternal = new File(getExternalFilesDir(null).toString()).getFreeSpace();
    

提交回复
热议问题