Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to safely remove SD card programmatically on Android

Tags:

android

api

I want to let the user safely remove the SD card in my program, but it seems the Android 2.2 public API does not provide a way to do this. Does anyone know what's a proper way to do it?

like image 276
Hong Jiang Avatar asked Jan 08 '11 02:01

Hong Jiang


People also ask

How do I delete pictures from my SD card on my gallery?

1 Open the My Files app. Note: On older devices you'll need to first select All Files and then select the SD Card option. Note: To delete files or folders, long press on the item you wish to remove, and select the Delete option in the top right of the screen.


1 Answers

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.

like image 133
Squonk Avatar answered Sep 17 '22 23:09

Squonk