I think I can use Intent.ACTION_DEVICE_STORAGE_LOW within a broadcast receiver to notify me when the device storage is low. Explained here.
I know that I could find out how much space the user has available here.
However, I want to avoid having to set a boundary of what is/isn't enough space available if possible. The OS gives the user a notification when the storage is low.
Question: Is there anyway of only showing an in app error message on boot if the OS thinks the space available is low?
A cache can come in the form of hardware or software, and its function is to store data so that future requests for that data can be processed and provided in less time. But a cache can also harbor data that you no longer need, and therefore takes up storage space without you even realizing it.
It is normal to try out new Apps but how many Apps do you have sitting in your device, that are no longer in use? Just like temporary internet files stored in computer, Apps store temporary files in device's internal memory which can pile up eventually and take up a considerable amount of space.
Per some related sample code from google you can take this route:
IntentFilter lowstorageFilter = new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW);
boolean hasLowStorage = registerReceiver(null, lowstorageFilter) != null;
In other words, there is a DeviceStorageMonitorService
service 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 as a way to just test if the sticky broadcast has been sent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With