如何获取android内部存储的可用空间,例如Photos或Download的文件夹...更具体,我需要访问由另一个应用程序创建的库的文件夹是WhatsApp照片文件夹。我是Android移动开发人员的新手,该公司认为这是一个挑战。我看到了一些技术,但他们只说了如何处理SD卡,我不知道如何申请INTERNAL模式。有人能帮助我吗?
提前谢谢。
File [] externalStorageFiles = ContextCompat.getExternalFilesDirs (this, null);
/ **
* We get the external directory
* /
File externalStorageDirectory = Environment.getExternalStorageDirectory ();
/ **
* We take the folder (Here you must enter the path you want)
* /
File downloadFolder = new File (externalStorageDirectory.getAbsolutePath () + "/ Download");
/ **
* If directory exists
* /
If (downloadFolder.exists ()) {
/ **
* Messages with folder information
* /
Toast.makeText (getApplicationContext (), downloadFolder.getUsableSpace () + "bytes used", Toast.LENGTH_SHORT) .show ();
Toast.makeText (getApplicationContext (), downloadFolder.getFreeSpace () + "free bytes", Toast.LENGTH_SHORT) .show ();
Toast.makeText (getApplicationContext (), downloadFolder.getTotalSpace () + "total bytes", Toast.LENGTH_SHORT) .show ();
If (null! = Folder.listFiles ()) {
Toast.makeText (getApplicationContext (), folder.listFiles (). Length + "files", Toast.LENGTH_SHORT) .show ();
}
} Else {
Toast.makeText (getApplicationContext (), "Directory does not exist", Toast.LENGTH_SHORT) .show ();
}