Android Check if there is not enough storage space when downloading the app

I think I can use Intent.ACTION_DEVICE_STORAGE_LOW on the broadcast receiver to notify me when the device memory is low. Explained here .

I know I can find out how much free space a user has available here .

However, I want to avoid having to set a boundary on what is / is not enough space if possible. OS gives user notification when storage is low.

Question : Is there generally an error message at boot if the OS thinks the available space is low?

+3


source to share


1 answer


For some example code from google you can follow this path:

IntentFilter lowstorageFilter = new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW);
boolean hasLowStorage = registerReceiver(null, lowstorageFilter) != null;

      



In other words, there is a service DeviceStorageMonitorService

that runs at the OS level and detects a low storage situation. From there, it sends a sticky broadcast that any activity or service can check later. In this example, they registered a null receiver just to check if a sticky broadcast was sent.

+8


source







All Articles