Friday, January 15, 2010

[android-developers] sd card storage state and detecting it being plugged in or not...

i have an app that needs to be able to write to the sdcard.

so, it goes without saying that I need to be able to detect if the
sdcard is being shared or not -- simple enough.
android.os.Environment.getExternalStorageState().equals
(android.os.Environment.MEDIA_SHARED)

if this is true, then my app does not have access to the SD card -
perfect.

I would also like to know while my app is running, if the state of the
SD card changes. It looks like I can create a BroadcastReceiver with
an IntentFilter that traps the event.

the problem is that that the system winds up killing my process
because it has a file open on the SD card.

01-15 17:33:44.091: ERROR/vold(47): KillProcessesWithOpenFiles /sdcard
01-15 17:33:44.322: ERROR/vold(47): process com.test.test (7351) has
open file /sdcard/test/logfile.txt

how can I prevent this?

tia.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate