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 Bitmap getImageFromSDCard(String name) {

    String SDCarePath = Environment.getExternalStorageDirectory().toString();
    String filePath = SDCarePath;
    return BitmapFactory.decodeFile(filePath + "/" + name);
}

From source file:Main.java

public static String getSDPath() {
    if (Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
        String sdDir = Environment.getExternalStorageDirectory().getPath();
        return sdDir;
    }/*from   www  .  j  a va  2  s. c o m*/
    return null;
}

From source file:Main.java

public static String getExternalDir() {
    final StringBuilder sb = new StringBuilder();
    sb.append(Environment.getExternalStorageDirectory().getAbsolutePath());
    sb.append("/xdrip");

    final String dir = sb.toString();
    return dir;/* ww w .ja v a  2 s  .  c  o m*/
}

From source file:Main.java

public static File getDefaultDirectory() throws Exception {
    File extdir = Environment.getExternalStorageDirectory();
    File directory = new File(extdir, SD_DIRECTORY + "/");
    directory.mkdirs();/*from w  ww  .j  ava  2  s.  c o m*/
    return directory;
}

From source file:Main.java

public static String getSDPath() {
    if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
        return Environment.getExternalStorageDirectory().getPath();
    }//from  www . j  av a2  s . co m
    return "";
}

From source file:Main.java

/**
 * Clears any leftover photos in our temporary folder.
 *//*from   www .  jav a2s.  c o m*/
public static void clearPhotos() {
    File tempDir = Environment.getExternalStorageDirectory();
    tempDir = new File(tempDir.getAbsolutePath() + "/bv-temp/");
    if (tempDir.listFiles() != null) {
        for (File photo : tempDir.listFiles()) {
            photo.delete();
        }
    }
}

From source file:Main.java

public static File getPiiicFile(Context paramContext, String paramString) {
    File localFile = new File(Environment.getExternalStorageDirectory(), "Piiic");
    if ((!localFile.exists()) || (localFile.isFile()))
        localFile.mkdirs();//from w ww .ja v  a  2  s  . co m
    return new File(localFile, paramString);
}

From source file:Main.java

public static boolean createDirectoryIfNecessary(String sdFolderName) {
    File dir = new File(Environment.getExternalStorageDirectory().getPath() + "/" + sdFolderName + "/");
    return !dir.exists() && dir.mkdirs();
}

From source file:Main.java

static public void mkdirSDContent() {
    try {//  w  ww  . j a  v  a2 s. com
        String swiftFolder = "/swift";
        String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
        File mySwiftFolder = new File(extStorageDirectory + swiftFolder);
        mySwiftFolder.mkdir();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static boolean checkFileExists(String name) {
    boolean status;
    if (!name.equals("")) {
        File path = Environment.getExternalStorageDirectory();
        File newPath = new File(path.toString() + name);
        status = newPath.exists();/*  w  w w .  j  a  va 2  s .  c  o m*/
    } else {
        status = false;
    }
    return status;
}