Java tutorial
//package com.java2s; //License from project: Apache License import android.os.Environment; import android.text.TextUtils; public class Main { private static String UNKNOWN = ""; /** * Returns the current state of the storage device that provides the given path. * @param state "getExternalStorageState()" */ public static String getExternalStorageState(String state) { if (TextUtils.isEmpty(state)) { return UNKNOWN; } switch (state) { case Environment.MEDIA_BAD_REMOVAL://bad_removal return "MEDIA_BAD_REMOVAL"; case Environment.MEDIA_CHECKING://checking return "MEDIA_CHECKING"; case Environment.MEDIA_EJECTING://ejecting return "MEDIA_EJECTING"; case Environment.MEDIA_MOUNTED://mounted return "MEDIA_MOUNTED"; case Environment.MEDIA_MOUNTED_READ_ONLY://mounted_read_only return "MEDIA_MOUNTED_READ_ONLY"; case Environment.MEDIA_NOFS://nofs return "MEDIA_NOFS"; case Environment.MEDIA_REMOVED://removed return "MEDIA_REMOVED"; case Environment.MEDIA_SHARED://shared return "MEDIA_SHARED"; case Environment.MEDIA_UNKNOWN://unknown return "MEDIA_UNKNOWN"; case Environment.MEDIA_UNMOUNTABLE://unmountable return "MEDIA_UNMOUNTABLE"; case Environment.MEDIA_UNMOUNTED://unmounted return "MEDIA_UNMOUNTED"; default: return UNKNOWN; } } }