13

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..

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.

[Edit]

I also run into this bite on Android issue tracker:

http://code.google.com/p/android/issues/detail?id=1653

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

[Edit2]

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"?

  • 1
    Presumably you can fill up the data partition and sdcard from an app, or if for some reason not, then on the emulator from the command line as root (where you can also make the SD card conveniently small). – Chris Stratton Jun 03 '11 at 19:52
  • thanks for those hints, though I'm mostly hoping for answers concerning the handling part. anyways, this is much appreciated :) – Dariusz Jędrzejczyk Jun 03 '11 at 19:58
  • To me the answer would be "Check how much diskspace your partition has before writing" - if it is too little then inform the user. A question/answer with some more information about querying for it: http://stackoverflow.com/questions/4595334/android-get-free-space-on-internal-memory – Smith3 Jun 03 '11 at 20:27
  • I'm curious if anyone uses this technique for every insert into a database table. Still it's a nice hint, thanks - but I'd prefer to get real guidelines, or examples of a commonly used pattern in the apps out there. I'll get some sleep and perhaps try to flood my disk and see how the apps behave.. – Dariusz Jędrzejczyk Jun 03 '11 at 20:36
  • @chemical : i am facing the same problem now with my app . If you have found any solution to such critical problem i would like to implement in my code . Thanks in advance – Shabbir Panjesha Nov 28 '12 at 06:54
  • 1
    @ShabbirPanjesha It seems in the end it's not up to the developers to care about the user not taking care of his storage. The system prompts the user before quite aggressively so if this severe situation happens there's nothing we can do. What we can do is: don't store massive amounts of data. Iteratively store the data you need (entries in the database, images one after another, etc.) instead of grabbing a huge bulk of data and flushing it to the disk. Let me know if this doesn't help you and you have a different type of issue. – Dariusz Jędrzejczyk Dec 09 '12 at 19:38

2 Answers2

1

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.

Community
  • 1
  • 1
Learn OpenGL ES
  • 4,759
  • 1
  • 36
  • 38
-1

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.