List of usage examples for android.os Environment MEDIA_SHARED
String MEDIA_SHARED
To view the source code for android.os Environment MEDIA_SHARED.
Click Source Link
From source file:Main.java
public static boolean isSdcardShared() { String state = Environment.getExternalStorageState(); return Environment.MEDIA_SHARED.equals(state); }
From source file:Main.java
public static void verifyExternalStorageAvailability() { String cardstatus = Environment.getExternalStorageState(); if (cardstatus.equals(Environment.MEDIA_REMOVED) || cardstatus.equals(Environment.MEDIA_UNMOUNTABLE) || cardstatus.equals(Environment.MEDIA_UNMOUNTED) || cardstatus.equals(Environment.MEDIA_MOUNTED_READ_ONLY) || cardstatus.equals(Environment.MEDIA_SHARED)) { RuntimeException e = new RuntimeException( "ODK reports :: SDCard error: " + Environment.getExternalStorageState()); throw e;/*from w w w .j ava 2 s.co m*/ } }
From source file:Main.java
/** * Returns the current state of the storage device that provides the given path. * @param state "getExternalStorageState()" */// w w w .ja v a 2s . c o m 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; } }
From source file:org.digitalcampus.oppia.utils.FileUtils.java
public static boolean createDirs(Context ctx) { String cardstatus = Environment.getExternalStorageState(); if (cardstatus.equals(Environment.MEDIA_REMOVED) || cardstatus.equals(Environment.MEDIA_UNMOUNTABLE) || cardstatus.equals(Environment.MEDIA_UNMOUNTED) || cardstatus.equals(Environment.MEDIA_MOUNTED_READ_ONLY) || cardstatus.equals(Environment.MEDIA_SHARED)) { Log.d(TAG, "card status: " + cardstatus); return false; }/* w ww .j a v a 2s. c om*/ String[] dirs = { FileUtils.getCoursesPath(ctx), FileUtils.getMediaPath(ctx), FileUtils.getDownloadPath(ctx) }; for (String dirName : dirs) { File dir = new File(dirName); if (!dir.exists()) { if (!dir.mkdirs()) { Log.d(TAG, "can't mkdirs"); return false; } } else { if (!dir.isDirectory()) { Log.d(TAG, "not a directory"); return false; } } } return true; }
From source file:com.mpower.mintel.android.application.MIntel.java
/** * Creates required directories on the SDCard (or other external storage) * /*from w w w . ja va 2 s . com*/ * @throws RuntimeException * if there is no SDCard or the directory exists as a non * directory */ public static void createMIntelDirs() throws RuntimeException { String cardstatus = Environment.getExternalStorageState(); if (cardstatus.equals(Environment.MEDIA_REMOVED) || cardstatus.equals(Environment.MEDIA_UNMOUNTABLE) || cardstatus.equals(Environment.MEDIA_UNMOUNTED) || cardstatus.equals(Environment.MEDIA_MOUNTED_READ_ONLY) || cardstatus.equals(Environment.MEDIA_SHARED)) { RuntimeException e = new RuntimeException( "mIntel reports :: SDCard error: " + Environment.getExternalStorageState()); throw e; } String[] dirs = { MINTEL_ROOT, FORMS_PATH, INSTANCES_PATH, CACHE_PATH, METADATA_PATH, PRESCRIPTION_PATH }; for (String dirName : dirs) { File dir = new File(dirName); if (!dir.exists()) { if (!dir.mkdirs()) { RuntimeException e = new RuntimeException( "mIntel reports :: Cannot create directory: " + dirName); throw e; } } else { if (!dir.isDirectory()) { RuntimeException e = new RuntimeException( "mIntel reports :: " + dirName + " exists, but is not a directory"); throw e; } } } String[] fileNames = { "pres_n.ogg", "call_n.ogg" }; copyAudioFiles(fileNames); }
From source file:com.nks.nksmod.otaupdater.DownloadsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String extState = Environment.getExternalStorageState(); if (!extState.equals(Environment.MEDIA_MOUNTED) && !extState.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) { Toast.makeText(this, extState.equals(Environment.MEDIA_SHARED) ? R.string.toast_nosd_shared : R.string.toast_nosd_error, Toast.LENGTH_LONG).show(); finish();/* www . jav a2 s . c om*/ } setContentView(R.layout.downloads); dlFragment = (DownloadListFragment) getFragmentManager().findFragmentById(R.id.download_list); bar = getActionBar(); assert bar != null; bar.setDisplayHomeAsUpEnabled(true); bar.setDisplayShowTitleEnabled(false); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); bar.setListNavigationCallbacks(ArrayAdapter.createFromResource(this, R.array.download_types, android.R.layout.simple_spinner_dropdown_item), this); int state = -1; String action = getIntent().getAction(); if (action != null) { if (action.equals(FLASH_ROM_ACTION)) { state = GOTO_TYPE_ROM; showFlashDialog(RomInfo.FACTORY.fromIntent(getIntent())); /* } else if (action.equals(FLASH_KERNEL_ACTION)) { state = GOTO_TYPE_KERNEL; showFlashDialog(KernelInfo.FACTORY.fromIntent(getIntent())); */ } else { state = getIntent().getIntExtra(EXTRA_GOTO_TYPE, state); } } if (savedInstanceState != null) { if (state == -1) state = savedInstanceState.getInt("state", dlFragment.getState()); } bar.setSelectedNavigationItem(state); }
From source file:org.digitalcampus.oppia.utils.storage.ExternalStorageStrategy.java
public boolean isStorageAvailable(Context ctx) { String cardStatus = Environment.getExternalStorageState(); if (cardStatus.equals(Environment.MEDIA_REMOVED) || cardStatus.equals(Environment.MEDIA_UNMOUNTABLE) || cardStatus.equals(Environment.MEDIA_UNMOUNTED) || cardStatus.equals(Environment.MEDIA_MOUNTED_READ_ONLY) || cardStatus.equals(Environment.MEDIA_SHARED)) { Log.d(TAG, "card status: " + cardStatus); return false; } else {/*from w ww .ja v a 2 s. co m*/ return true; } }
From source file:com.otaupdater.DownloadsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String extState = Environment.getExternalStorageState(); if (!extState.equals(Environment.MEDIA_MOUNTED) && !extState.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) { Toast.makeText(this, extState.equals(Environment.MEDIA_SHARED) ? R.string.toast_nosd_shared : R.string.toast_nosd_error, Toast.LENGTH_LONG).show(); finish();//from ww w. ja v a2 s . c o m } setContentView(R.layout.downloads); dlFragment = (DownloadListFragment) getFragmentManager().findFragmentById(R.id.download_list); Fragment adFragment = getFragmentManager().findFragmentById(R.id.ads); if (adFragment != null) getFragmentManager().beginTransaction().hide(adFragment).commit(); bar = getActionBar(); assert bar != null; bar.setDisplayHomeAsUpEnabled(true); bar.setDisplayShowTitleEnabled(false); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); bar.setListNavigationCallbacks(ArrayAdapter.createFromResource(this, R.array.download_types, android.R.layout.simple_spinner_dropdown_item), this); int state = -1; String action = getIntent().getAction(); if (action != null) { if (action.equals(FLASH_ROM_ACTION)) { state = GOTO_TYPE_ROM; showFlashDialog(RomInfo.FACTORY.fromIntent(getIntent())); } else if (action.equals(FLASH_KERNEL_ACTION)) { state = GOTO_TYPE_KERNEL; showFlashDialog(KernelInfo.FACTORY.fromIntent(getIntent())); } else { state = getIntent().getIntExtra(EXTRA_GOTO_TYPE, state); } } if (savedInstanceState != null) { if (state == -1) state = savedInstanceState.getInt("state", dlFragment.getState()); } bar.setSelectedNavigationItem(state); }
From source file:com.radicaldynamic.groupinform.application.Collect.java
/** * Creates required directories on the SDCard (or other external storage) * @throws RuntimeException if there is no SDCard or the directory exists as a non directory *///from w w w . j a va 2s . c o m public static void createODKDirs() throws RuntimeException { String cardstatus = Environment.getExternalStorageState(); if (cardstatus.equals(Environment.MEDIA_REMOVED) || cardstatus.equals(Environment.MEDIA_UNMOUNTABLE) || cardstatus.equals(Environment.MEDIA_UNMOUNTED) || cardstatus.equals(Environment.MEDIA_MOUNTED_READ_ONLY) || cardstatus.equals(Environment.MEDIA_SHARED)) { RuntimeException e = new RuntimeException( "ODK reports :: SDCard error: " + Environment.getExternalStorageState()); throw e; } String[] dirs = { ODK_ROOT, FORMS_PATH, INSTANCES_PATH, CACHE_PATH, METADATA_PATH }; for (String dirName : dirs) { File dir = new File(dirName); if (!dir.exists()) { if (!dir.mkdirs()) { RuntimeException e = new RuntimeException("ODK reports :: Cannot create directory: " + dirName); throw e; } } else { if (!dir.isDirectory()) { RuntimeException e = new RuntimeException( "ODK reports :: " + dirName + " exists, but is not a directory"); throw e; } } } }
From source file:it.fabaris.wfp.application.Collect.java
/** * Creates required directories on the SDCard (or other external storage) * @throws RuntimeException if there is no SDCard or the directory exists as a non directory *///from w w w. jav a 2s . c om public static void createODKDirs() throws RuntimeException { String cardstatus = Environment.getExternalStorageState(); if (cardstatus.equals(Environment.MEDIA_REMOVED) || cardstatus.equals(Environment.MEDIA_UNMOUNTABLE) || cardstatus.equals(Environment.MEDIA_UNMOUNTED) || cardstatus.equals(Environment.MEDIA_MOUNTED_READ_ONLY) || cardstatus.equals(Environment.MEDIA_SHARED)) { RuntimeException e = new RuntimeException( "ODK reports :: SDCard error: " + Environment.getExternalStorageState()); throw e; } String[] dirs = { FABARISODK_ROOT, FORMS_PATH, INSTANCES_PATH, CACHE_PATH, METADATA_PATH }; // String[] dirs_Ext = {FABARISODK_ROOT_Ext, FORMS_PATH_Ext, INSTANCES_PATH_Ext, CACHE_PATH_Ext, METADATA_PATH_Ext}; for (String dirName : dirs) { File dir = new File(dirName); if (!dir.exists()) { if (!dir.mkdirs()) { RuntimeException e = new RuntimeException("ODK reports :: Cannot create directory: " + dirName); throw e; } } else { if (!dir.isDirectory()) { RuntimeException e = new RuntimeException( "ODK reports :: " + dirName + " exists, but is not a directory"); throw e; } } } }