Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I listen for SD card mounting in android?

I have a program that uses the SD card, so I want to be informed if the state of the card changes by registering a listener if possible. I'm aware of the Environment class and its methods, but I don't really want to be constantly polling the state. I'd rather not have my program force close when running cause someone mounted the sd card to their computer.

like image 340
yincrash Avatar asked Jan 17 '10 20:01

yincrash


1 Answers

Create a BroadcastReceiver for ACTION_MEDIA_MOUNTED and related intents.

like image 102
Mirko N. Avatar answered Sep 27 '22 22:09

Mirko N.