# What happens when an SDcard is inserted?

I have a rooted Sony Tablet S, and one of my issues with it is that there is little onboard storage. The Sony-recommended way of dealing with this is to transfer files between internal and external storage, as many apps do not have access to the external storage.

Having rooted the device, however, I am able to use mount -o bind /mnt/sdcard2 /mnt/sdcard/2 to mount this. I was then intending to rename the media folder on my external sdcard to .media, and use mount -o bind /mnt/sdcard2/.media/$F /mnt/sdcard/media/$F/external for each folder \$F in that directory. The problem with this is that on removal of the external sdcard, or on reboot, these mounts are lost.

On my Maemo phone I did something similar, and was able to have this mount behaviour occur when the external storage was attached. As Maemo5 is a truly open OS I was able to do this fairly easily, and there was a lot of community support.

When trying to do the same under Android I have come across an app called Tasker that performs actions as I would need, however this is paid software and I would prefer not to have to install something that performs actions which should be build into the operating system.

## TLDR;

I'd like to know what is actually happening on my device when an SDcard is inserted - are scripts run? Are signals sent which could be used to trigger scripts? Has anyone attempted to do similar (I don't understand why this would not be the default behaviour to be honest - the fact that external storage is hidden from apps is frustrating to say the least)

• Android in general handles SD cards more nicely than this, I think it's just your device. That said, there are events broadcast when the SD card is inserted; that's what Tasker would use. You could certainly write your own app to do the same. – Matthew Read Mar 7 '12 at 18:37
• @Matthew if you could point me towards some of the resources that would be useful for this, I would consider that enough for an answer. I have experience writing software but am new to Android, I have not found it easy to find resources on what this would require. – theheadofabroom Mar 8 '12 at 14:47
• Dev questions are off-topic here unfortunately, and I haven't done any Android development myself. However, this might help: developer.android.com/reference/android/content/Intent.html – Matthew Read Mar 8 '12 at 16:49