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 createStorageFolder(String name) {
    File extStorageDirectory = Environment.getExternalStorageDirectory();
    File f = new File(extStorageDirectory, name);
    f.mkdirs();/*from ww w  .j  ava2s . c om*/
    return f;
}

From source file:Main.java

public static String makeDir(String dirName) {
    String mRootPath = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + dirName;

    try {/*from  www . j a v a 2 s .c  om*/
        File fRoot = new File(mRootPath);
        if (fRoot.exists() == false) {
            if (fRoot.mkdirs() == false) {
                throw new Exception("");
            }
        }
    } catch (Exception e) {
        mRootPath = "-1";
    }

    return mRootPath + "/";
}

From source file:Main.java

public static Boolean LanguageFilePresentCheck() {
    File ftxtFile = new File(Environment.getExternalStorageDirectory() + "/WFP/Language/Language.txt");
    if (ftxtFile.exists()) // check if file exist
    {/*w w  w. j a v  a 2s  .c o  m*/
        return true;
    } else {
        return false;
    }
}

From source file:Main.java

public static File getSDCardFile() {
    if (isSDCardEnable()) {
        return Environment.getExternalStorageDirectory();
    } else {/*from www . j  ava  2s. c  o  m*/
        return null;
    }
}

From source file:Main.java

public static String makeDir(String str) {
    String s = Environment.getExternalStorageDirectory().getAbsolutePath() + str;
    File dir = new File(s);
    dir.mkdirs();/*  ww w . ja  v  a 2s. co m*/

    return s;
}

From source file:Main.java

public static String getCamerPath() {
    return Environment.getExternalStorageDirectory() + File.separator + "FounderNews" + File.separator;
}

From source file:Main.java

public static long availableSDCard() {
    File path = Environment.getExternalStorageDirectory();
    long availableSize = 0;
    if (path != null) {
        StatFs stat = new StatFs(path.getPath());
        long blockSize = stat.getBlockSize();
        long availableBlock = stat.getAvailableBlocks();
        availableSize = availableBlock * blockSize;
    }/*from  ww  w  . j a  v a2s.co m*/

    return availableSize / (1024 * 1024);
}

From source file:Main.java

public static String getExtPath() {
    String path = "";
    if (hasSDCard()) {
        path = Environment.getExternalStorageDirectory().getPath();
    }/*from   ww w  .  j  ava 2s. c  om*/
    return path;
}

From source file:Main.java

public static void deleteFile(String fileName) {
    File file = new File(
            Environment.getExternalStorageDirectory().getPath() + "/kidsedu/temp" + File.separator + fileName);
    if (file.exists()) {
        file.delete();// w w w. ja  va  2 s  . c o m
    }
}

From source file:Main.java

public static File getPhotoDir() {
    File root_dir = Environment.getExternalStorageDirectory();
    File photo_tmp_dir = new File(root_dir, "YYData/images/photos");
    return photo_tmp_dir;
}