Example usage for android.os Environment MEDIA_UNMOUNTED

List of usage examples for android.os Environment MEDIA_UNMOUNTED

Introduction

In this page you can find the example usage for android.os Environment MEDIA_UNMOUNTED.

Prototype

String MEDIA_UNMOUNTED

To view the source code for android.os Environment MEDIA_UNMOUNTED.

Click Source Link

Document

Storage state if the media is present but not mounted.

Usage

From source file:com.android.server.MountService.java

public void unmountVolume(String path, boolean force, boolean removeEncryption) {
    validatePermission(android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS);
    waitForReady();//from   w  w w.ja va2  s  . c om

    String volState = getVolumeState(path);
    if (DEBUG_UNMOUNT) {
        Slog.i(TAG, "Unmounting " + path + " force = " + force + " removeEncryption = " + removeEncryption);
    }
    if (Environment.MEDIA_UNMOUNTED.equals(volState) || Environment.MEDIA_REMOVED.equals(volState)
            || Environment.MEDIA_SHARED.equals(volState) || Environment.MEDIA_UNMOUNTABLE.equals(volState)) {
        // Media already unmounted or cannot be unmounted.
        // TODO return valid return code when adding observer call back.
        return;
    }
    UnmountCallBack ucb = new UnmountCallBack(path, force, removeEncryption);
    mHandler.sendMessage(mHandler.obtainMessage(H_UNMOUNT_PM_UPDATE, ucb));
}