Example usage for android.os Environment getExternalStorageDirectory

List of usage examples for android.os Environment getExternalStorageDirectory

Introduction

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

Prototype

public static File getExternalStorageDirectory() 

Source Link

Document

Return the primary shared/external storage directory.

Usage

From source file:Main.java

public static File getExternalStorageDir() {
    return Environment.getExternalStorageDirectory();
}

From source file:Main.java

public static long getExternalStorageFreeSpace() {

    File path = Environment.getExternalStorageDirectory();
    StatFs stat = new StatFs(path.getPath());

    return stat.getAvailableBlocks() * stat.getBlockSize();
}

From source file:Main.java

public static File getSdcardFile() {
    return new File(Environment.getExternalStorageDirectory().getAbsolutePath());
}

From source file:Main.java

public static float getSDCardFreeSize() {
    try {/*w  ww . j a v a2  s.  c  o m*/
        String path = Environment.getExternalStorageDirectory().getPath();
        StatFs fs = new StatFs(path);
        return calculateSizeInMB(fs);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return 0;
}

From source file:Main.java

public static void CreateCustomFolderForLanguage() {
    File direct = new File(Environment.getExternalStorageDirectory() + "/WFP/Language/");

    if (!direct.exists()) {
        if (direct.mkdir()) {
            File languageFolder = new File("/WFP/Language/");
            languageFolder.mkdirs();/*from  w  w  w .ja v a 2s.c  om*/
        }

    } else {

    }

}

From source file:Main.java

public static String getSDCardDir() {
    //      return activity.getExternalFilesDir(null).getAbsolutePath();
    return Environment.getExternalStorageDirectory().getAbsolutePath();
}

From source file:Main.java

public static void clearLog() {
    File logFile = new File(Environment.getExternalStorageDirectory() + "/clr_log.file");
    PrintWriter writer;/* www .  j a v a  2 s .c o  m*/
    try {
        writer = new PrintWriter(logFile);
        writer.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static File getCanonCWGeoLogPath() {
    return new File(Environment.getExternalStorageDirectory(), "Canon CW/.geolog/");
}

From source file:Main.java

public static String getSDCardPath() {
    if (isSDCardExist()) {
        File file = Environment.getExternalStorageDirectory();
        return file.getPath();
    } else {/*w  w  w  .j a  v  a 2 s.com*/
        return null;
    }
}

From source file:Main.java

public static String getAbsolutePathOnExternalStorage(final String pFilePath) {
    return Environment.getExternalStorageDirectory() + "/" + pFilePath;
}