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 String getSdcardPath() {
    return Environment.getExternalStorageDirectory().getAbsolutePath();
}

From source file:Main.java

public static long freeSpaceOnSd() {
    StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
    long sdFreeMB = (long) stat.getAvailableBlocks() * stat.getBlockSize();
    return sdFreeMB;
}

From source file:Main.java

public static String getRootFilePath() {
    if (hasSDCard()) {
        return Environment.getExternalStorageDirectory().getAbsolutePath() + "/";// filePath:/sdcard/
    } else {//from  w w w. ja va  2s  .c o  m
        return Environment.getDataDirectory().getAbsolutePath() + "/data/"; // filePath: /data/data/
    }
}

From source file:Main.java

public static File getApkFile(String apkTitle) {
    File file = new File(Environment.getExternalStorageDirectory().getPath() + "/Download", apkTitle);
    return file;/* w  w  w .ja  v a2  s . c om*/
}

From source file:Main.java

public static String getSDPath() {
    if (checkSDCardAvailabel()) {
        return Environment.getExternalStorageDirectory().getPath();
    } else {//from  w w  w  .j  av a  2 s.  com
        return Environment.getDownloadCacheDirectory().getPath();
    }

}

From source file:Main.java

public static void deleteCSV() {

    File myDir = new File(Environment.getExternalStorageDirectory() + "/Caffeine_Counter_History");

    deleteRecursive(myDir);/* w  w w. j av  a  2  s.  c  o m*/

}

From source file:Main.java

static public void deleteAllSDContent() {
    String dir_path = Environment.getExternalStorageDirectory().getPath() + "/swift";
    File f = new File(dir_path);
    if (f.isDirectory()) {
        String files[] = f.list();
        for (int i = 0; i < files.length; i++) {
            new File(dir_path, files[i]).delete();

        }//from w w  w .ja v a  2 s  . c  om
    }
}

From source file:Main.java

public static String getSdcardPath() {
    String sdcardPath = Environment.getExternalStorageDirectory().getAbsolutePath();
    return sdcardPath;
}

From source file:Main.java

public static String getExternalStorageDirectory() {
    return Environment.getExternalStorageDirectory().getAbsolutePath();
}

From source file:Main.java

public static URI getSDCardUri() {
    if (existSDCard())
        return Environment.getExternalStorageDirectory().toURI();
    else/*w w w  .  j  av a  2  s  .  co  m*/
        return null;
}