Handling full disk storage in Android

This question has evolved a bit from the initial one, here’s a short info:

I filled up the disk storage on the emulator and got it absolutely useless – the process android.process.acore is displaying the “… has stopped unexpectedly” dialog in a loop, so nothing can be done on the system. I can’t even turn it off with the power button on the right (it’s tried to power off for 10 minutes now, logcat is full of exceptions). Great it’s an emulator, I wonder what would happen if it was my real device..

  • How do I run code in the UI thread in an Android JUnit test without an Activity?
  • How do I detect a cancel click of the datepicker dialog?
  • GridLayout(not GridView) - Spaces between the cells
  • Android setOnScrollListner on RecyclerView deprecated
  • Android: Multiple Notifications as single list in Status Bar
  • Purpose of describeContents() of Parcelable interface
  • Maybe someone can elaborate on the reasons for this behavior – should it be like this?

    Here’s the initial question, please also refer to my edits:

    I’m curious about handling a random situation such as running out of disk storage on an Android device.

    I looked over the examples on developer.android.com and I see they don’t even bother to do exception handling.

    I can see that when it comes to SQLite classes, there are a couple of exceptions, such as SQLiteOutOfMemoryException, but I can’t find any information when and how to handle these scenarios.

    Does anyone have experience with:

    • bulletproofing an app for such an edgy situation
    • ways to test this on an emulator
    • feedback from frustrated users (maybe heard of any frustration with the example-apps or even core apps..?)

    Thanks in advance for your time guys.


    I also run into this bite on Android issue tracker:


    It’s kind of mysterious.. and seems it’s a ghost since 2008.


    Alrite, with the advice from the comments: I just did a test using:

    dd if=/dev/urandom of=file

    with parameters bs and count chosen to fit the remaining space,

    and filled the /data partition.

    How amazed I am that Google Maps just crashed on the SQLiteFullException. Actually all the apps crash – even Phone.

    Is it true that nobody handles those exceptions? Is it ok that those applications just get killed with the “..has stopped unexpectedly”?

    Related posts:

    How do I get a jacoco coverage report using Android gradle plugin 0.10.0 or higher?
    How to add a line at the bottom of spinner as like edittext in android
    Custom ListView with Pinned Header , causing Jank when setting padding
    What does repo init and repo sync actually do?
    android.support.design.widget.FloatingActionButton implenetation of FAB reduces image size
    ContentObserver should call if and only if ContactsContract.Contacts.CONTENT_URI changes
  • An alternative to Android's webview
  • onTouchEvent executes twice
  • How to detect no of camera's available in android device? and also if the device has front camera how to use it?
  • Methods to get position of view returns 0
  • Android - Vertical layout only
  • Resizing layouts dynamically with ViewFlipper
  • 2 Solutions collect form web for “Handling full disk storage in Android”

    This is the error, “phone storage is full! Delete some files to free space.” I have at least 7 gigs of free space.
    Your phone’s internal memory is full. Not your memory card. They are entirely seperate.

    Try uninstalling some apps that you don’t need anymore. And also try clearing cache on some of your apps.

    The way I handle this is with error handling around all file operations so that the app won’t just crash, and I do a file stat (https://stackoverflow.com/a/5083482/1317564) on the directory being used by the user to ensure there’s enough free space. If not, I show them a nice big error message. 😉 Generally the phone itself will do plenty of complaining as well, so they should notice the problem sooner or later.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.