Code example for StorageManager

Methods: isUsbMassStorageConnected

0
 
    public StorageNotification(Context context) {
        mContext = context;
 
        mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
        mUmsAvailable = mStorageManager.isUsbMassStorageConnected();
        Slog.d(TAG, String.format( "Startup with UMS connection %s (media state %s)", mUmsAvailable,
                Environment.getExternalStorageState()));
    } 
 
    /* 
     * @override com.android.os.storage.StorageEventListener 
     */ 
    @Override 
    public void onUsbMassStorageConnectionChanged(boolean connected) {
        mUmsAvailable = connected;
        /* 
         * Even though we may have a UMS host connected, we the SD card 
         * may not be in a state for export. 
         */ 
Contextual code suggestions in your IDE  Get Codota for Java