Example usage for android.os Environment MEDIA_MOUNTED

List of usage examples for android.os Environment MEDIA_MOUNTED

Introduction

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

Prototype

String MEDIA_MOUNTED

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

Click Source Link

Document

Storage state if the media is present and mounted at its mount point with read/write access.

Usage

From source file:Main.java

public static boolean sdCardIsWork() {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        return true;
    }//from   w  w w.  j a  v a 2 s.  co  m
    return false;
}

From source file:Main.java

public static boolean checkSD() {
    String status = Environment.getExternalStorageState();
    if (status.equals(Environment.MEDIA_MOUNTED)) {
        return true;
    } else {//w w w. j  a v a2 s .c  o m
        return false;
    }
}

From source file:Main.java

/**
 * Returns whether or not there is an SD card mounted.
 * @return true if an SD card is mounted, otherwise false.
 *///www  .  j  av  a2  s.  c  o m
public static boolean isSDCardMounted() {
    return android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
}

From source file:com.docd.purefm.test.JavaFileTest.java

@Override
protected void setUp() throws Exception {
    super.setUp();
    try {// w  w w. j  a v  a2  s  .  c  om
        FileUtils.forceDelete(testDir);
    } catch (IOException e) {
        //ignored
    }

    final String state = Environment.getExternalStorageState();
    if (!state.equals(Environment.MEDIA_MOUNTED)) {
        throw new RuntimeException(
                "Make sure the external storage is mounted read-write before running this test");
    }
    try {
        FileUtils.forceDelete(testDir);
    } catch (IOException e) {
        //ignored
    }
    assertTrue(testDir.mkdirs());

    // prepare a test file
    try {
        FileUtils.write(test1, "test");
    } catch (IOException e) {
        throw new RuntimeException("Failed to create test file: " + e);
    }
}

From source file:ie.programmer.catcher.browser.FileBrowserEngine.FileBrowserEngine.java

public static boolean isMediaMounted() {
    return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
}

From source file:Main.java

/**
 * Returns application cache directory. Cache directory will be created on SD card
 * <i>("/Android/data/[app_package_name]/cache")</i> if card is mounted. Else - Android defines cache directory on
 * device's file system.//from w  ww. ja v a  2s.com
 * 
 * @param context Application context
 * @return Cache {@link File directory}
 */
public static File getCacheDirectory(Context context) {
    File appCacheDir = null;
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        appCacheDir = getExternalCacheDir(context);
    }
    if (appCacheDir == null) {
        appCacheDir = context.getCacheDir();
    }
    return appCacheDir;
}

From source file:com.docd.purefm.test.PFMFileUtilsTest.java

@Override
protected void setUp() throws Exception {
    super.setUp();
    final String state = Environment.getExternalStorageState();
    if (!state.equals(Environment.MEDIA_MOUNTED)) {
        throw new RuntimeException(
                "Make sure the external storage is mounted read-write before running this test");
    }/* w w  w  . j av a  2 s. com*/
    try {
        FileUtils.forceDelete(testDir);
    } catch (IOException e) {
        //ignored
    }
    assertTrue(testDir.mkdirs());
}

From source file:com.docd.purefm.test.MediaStoreUtilsTest.java

@Override
protected void setUp() throws Exception {
    super.setUp();
    assertTrue(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED));

    doTearDown();/* w  ww  . j  a  va  2s .c o m*/
    TEST_ROOT.mkdirs();
    assertTrue(TEST_ROOT.exists());
    assertTrue(TEST_ROOT.isDirectory());
}

From source file:com.docd.purefm.test.FileFactoryTest.java

@Override
protected void setUp() throws Exception {
    super.setUp();
    try {/*from w ww.j  a  va  2 s .  c  o  m*/
        FileUtils.forceDelete(testDir);
    } catch (IOException e) {
        //ignored
    }

    final String state = Environment.getExternalStorageState();
    if (!state.equals(Environment.MEDIA_MOUNTED)) {
        throw new RuntimeException(
                "Make sure the external storage is mounted read-write before running this test");
    }
    try {
        FileUtils.forceDelete(testDir);
    } catch (IOException e) {
        //ignore
    }
    assertTrue(testDir.mkdirs());
}

From source file:com.zeusky.star.star.java

public static void createSharePicDir() {
    boolean sdCardExist = Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);

    if (!sdCardExist) {
        Toast.makeText(m_instance, "???", Toast.LENGTH_SHORT).show();
    } else {/*w w w . ja va2  s  . co  m*/
        String dir = Environment.getExternalStorageDirectory() + File.separator + "zeusky.popstar";
        Log.d("shareSDK", "I am need this dir " + dir);
        File snapShotDir = new File(dir);
        if (!snapShotDir.exists()) {
            snapShotDir.mkdir();
        }
        methodsRun.injectOtherDir(dir + File.separator);
    }
}