Android 2.1 programmatically unmount SDCard
You should unmount what's using the sdcard in the proper order, for example
umount /mnt/sdcard/.android_secure
umount /mnt/sdcard
or, probably synchronizing the buffers with the filesystem would be enough
sync; sync
How to safely remove SD card programmatically on Android
You need to take the user to the device's built-in Settings. I think this will work.
Intent i = new Intent(android.provider.Settings.ACTION_MEMORY_CARD_SETTINGS);
startActivity(i);
Unmounting the SD card is one of those actions which could be used maliciously if it wasn't under full user control. If it could be done purely in software (without user intervention) then code could disrupt other apps running on the device.
Android Camera App - Have to Remount SD Card?
You can't mount/unmount the SD card (external storage) from an app. You probably need to call media scanner to get your picture indexed. Look at here and here for pointers. There is also an sample app that comes with the SDK. BTW, what Android version are you testing on?
Delete a folder on SD card
You have to have all the directory empty before deleting the directory itself, see here
In Android, you should have the proper permissions as well - WRITE_EXTERNAL_STORAGE
in your manifest.
EDIT: for convenience I copied the code here, but it is still from the link above
public static boolean deleteDirectory(File path) {
if( path.exists() ) {
File[] files = path.listFiles();
if (files == null) {
return true;
}
for(int i=0; i<files.length; i++) {
if(files[i].isDirectory()) {
deleteDirectory(files[i]);
}
else {
files[i].delete();
}
}
}
return( path.delete() );
}
How to delete a file from SD card
File file = new File(selectedFilePath);
boolean deleted = file.delete();
where selectedFilePath is the path of the file you want to delete - for example:
/sdcard/YourCustomDirectory/ExampleFile.mp3
Related Topics
Detect from Browser If a Specific Application Is Installed in Android
Android: Speech Recognition Without Using Google Server
How to Prevent a Service from Being Killed by Os
Selecting Multiple Items in Listview
Android Startcamera Gives Me Null Intent and ... Does It Destroy My Global Variable
How to Prevent Android Bluetooth Rfcomm Connection from Dying Immediately After .Connect()
How to Make a Scroll Listener for Webview in Android
Noclassdeffounderror with Android Studio on Android 4
Android Failed to Start Emulator:Cannot Run Program
How to Reference Style Attributes from a Drawable
Android Background Image Size in Pixel
Android: Binding Data from a Database to a Checkbox in a Listview
Android: How to Make a Clickable Map Image with Each Country Producing a Different Action