我无法指出getFreeSpace()和阶级getUsableSpace()方法之间的确切区别File.当我运行以下代码时,得到相同的o/p.
Class Start {
public static void main(String [] args) {
File myfile = new File("C:\\html\abc.txt");
myfile.createNewFile();
Systyem.out.println("free space"+myfile.getFreeSpace()+"usable space"+myfile.getUsableSpace());")
}
}
Run Code Online (Sandbox Code Playgroud)
O/P是
免费space445074731008可用空间445074731008
谁能告诉我究竟有什么区别?
在我的应用程序中,我已注册广播接收器以接收系统意图ACTION_DEVICE_STORAGE_LOW.我希望每当手机内存不足时就播放这个内容.所以,我下载了一些额外的应用程序(我的手机有一个非常小的内部存储器),导致操作系统显示系统内存不足的通知.手机剩下10-15 MB.但是,我的广播接收器从未收到过这种意图.然而,系统通知保留在通知栏中,由于内存不足,我无法浏览互联网.
每当显示低内部存储器通知时,是否应该广播此意图?或者是否有一些甚至更低的内存阈值将发送我尚未在手机上播放的广播?在文档中,它只说"广播操作:指示设备上存储器状况不佳的粘性广播".因为它实际上并没有定义"低记忆条件",所以我不知道我做错了什么,或者我还没有达到这个条件.
这是我的BroadCastReceiver的代码:
public class MemoryBroadcastReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(Intent.ACTION_MEDIA_MOUNTED)) {
Log.isExternalStorageProblem = false;
Log.clearNotification(Log.externalMemoryNotificationID);
}
if (action.equals(Intent.ACTION_DEVICE_STORAGE_OK)) {
Log.isInternalStorageLow = false;
Log.clearNotification(Log.internalMemoryNotificationID);
}
if (action.equals(Intent.ACTION_DEVICE_STORAGE_LOW)) {
Log.isInternalStorageLow = true;
Log.displayMemoryNotification("Internal Storage Low",
"The internal storage is low, Please fix this.",
"Please clear cache and/or uninstall apps.", Log.internalMemoryNotificationID);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个初始化接收器的服务,添加了intent过滤器并注册它(以及其他内容):
private MemoryBroadcastReceiver memoryBroadcastReciever = new MemoryBroadcastReceiver();
public void registerBroadcastReceiver() {
IntentFilter filter = new IntentFilter(); …Run Code Online (Sandbox Code Playgroud)