3

I don't have an Android device to test this (yeah, i know. Android developer without an Android device) but i was wondering if in case there is either NO sdcard in the device, or the sdcard is full, when i need to store some data during the execution of my app, will it return an IOException? Or will it just store it automatically in the phone's memory? OR what happens in this situation, and what are the best steps to pursue?

3
  • 1
    It will thrown IOException with message No space left on the device
    – Blackbelt
    Jul 17, 2012 at 9:15
  • And when it does that, i should try writing on the phone's memory right? And if that throws an exception as well, i should just tell the user he hasn't got enough memory? Is this the correct procedure? Jul 17, 2012 at 9:16
  • 2
    Best option IMO is always to inform the user and let him free same space. Avoid writing the phone memory
    – Blackbelt
    Jul 17, 2012 at 9:25

2 Answers 2

4

you could check if the sd card is mounted or not

Is there a way to tell if the sdcard is mounted vs not installed at all?

EDIT: you can check the availaible space in your phone (sdcard/internal)

How to Check available space on android device ? on SD card?

you might find this useful too.. An IOException IS thrown if you exceed the storage limit.

IOException is thrown when SDCard is full

2
  • And if i can't use the sdcard for whatever reason, they i should try writing on the phone's memory? And if that doesn't work as well, then i should just display a message to the user? Jul 17, 2012 at 9:19
  • that works. as long as your app logic allows to do each of those without creating a problem
    – Vinay W
    Jul 17, 2012 at 9:20
1

You can setup the emulator so it uses a SD card and then fill it up with for example "dd". This should give you an environment you can use to test your application in the case when there is no room left on your SD card.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.