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 getSaveDirPath() {
    return Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + FILE_SAVE;
}

From source file:Main.java

static public String checkFile(String fileName, String dir) {
    File dictionaryRoot = new File(Environment.getExternalStorageDirectory(), dir);
    File dictionaryFile = new File(dictionaryRoot, fileName.substring(0, 1));
    File filePath = new File(dictionaryFile, fileName + ".mp3");
    if (filePath.exists()) {
        return filePath.getAbsolutePath();
    }//from ww w . jav a  2s  .  c o  m
    return null;
}

From source file:Main.java

public static File getAudioPath(String fileName, String folderName) {
    File file = new File(Environment.getExternalStorageDirectory() + File.separator + "InstavoiceBlogs"
            + File.separator + "audio" + File.separator + folderName);
    if (!file.exists()) {
        file.mkdirs();//  w ww . j a  va 2 s .  com
    }
    File audioFile = new File(file, "aud_" + fileName);
    return audioFile;
}

From source file:Main.java

public static String getDatePhotoName() {
    String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath();
    Date date = new Date(System.currentTimeMillis());
    SimpleDateFormat dateFormat = new SimpleDateFormat("'IMG'_yyyyMMdd_HHmmss");
    return dateFormat.format(date) + ".JPG";
}

From source file:Main.java

public static long getSdCardAvailableSize() {
    File sdcardDir = Environment.getExternalStorageDirectory();
    StatFs sf = null;// w  w  w . j  a  va  2  s.  com
    try {
        sf = new StatFs(sdcardDir.getPath());
    } catch (Exception e) {
        return 0;
    }
    long blockSize = sf.getBlockSize();
    long availCount = sf.getAvailableBlocks();
    return availCount * blockSize;
}

From source file:Main.java

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

From source file:Main.java

public static File createTemporaryFile(String part, String ext) throws Exception {
    File tempDir = Environment.getExternalStorageDirectory();
    tempDir = new File(tempDir.getAbsolutePath() + "/.temp/");
    if (!tempDir.exists()) {
        tempDir.mkdirs();//from   w  w  w . j a v a  2 s .  c om
    }
    return File.createTempFile(part, ext, tempDir);
}

From source file:Main.java

public static File createTemporaryFile(String part, String ext) throws Exception {
    File tempDir = Environment.getExternalStorageDirectory();
    tempDir = new File(tempDir.getAbsolutePath() + "/.temp/");
    if (!tempDir.exists()) {
        tempDir.mkdir();/*from  w  w  w .  jav  a2 s . c om*/
    }
    return File.createTempFile(part, ext, tempDir);
}

From source file:Main.java

public static File getExternalStoragePath() {
    if (isExternalStoragePresent()) {
        return Environment.getExternalStorageDirectory();
    }/*from  w  w  w  .j  a v a2 s.c  o  m*/
    return null;
}

From source file:Main.java

public static File getImageCache() {
    return new File(Environment.getExternalStorageDirectory() + "/" + FlipNewsDir + "/");
}