How to safely remove SD card programmatically on Android

后端 未结 2 1655
既然无缘
既然无缘 2020-12-11 04:46

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

2条回答
  •  既然无缘
    2020-12-11 05:26

    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.

提交回复
热议问题