List of usage examples for android.os Environment getExternalStorageDirectory
public static File getExternalStorageDirectory()
From source file:Main.java
public static long getAvailableExternalSpace() { File path = new File(Environment.getExternalStorageDirectory().getAbsolutePath()); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); return availableBlocks * blockSize; }
From source file:Main.java
public static File getBackupDir() { return new File(Environment.getExternalStorageDirectory(), "episodes"); }
From source file:Main.java
public static String extStorageDir(String packageName) { // To be safe, you should check that the SDCard is mounted // using Environment.getExternalStorageState() before doing this. File mediaStorageDir = new File(Environment.getExternalStorageDirectory() + "/Android/data/" //+ getApplicationContext().getPackageName() + packageName + "/Files"); // This location works best if you want the created images to be shared // between applications and persist after your app has been uninstalled. // Create the storage directory if it does not exist if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { return null; }/*from ww w . ja v a 2 s. c o m*/ } return mediaStorageDir.getPath() + File.separator; }
From source file:Main.java
public static File getFinancistoBackupFolder() { return new File(Environment.getExternalStorageDirectory() + File.separator + "financisto"); }
From source file:Main.java
public static String getBootImagePath(String romId) { return Environment.getExternalStorageDirectory() + File.separator + "MultiBoot" + File.separator + romId + File.separator + "boot.img"; }
From source file:Main.java
public static String getSdCardRootPath() { return Environment.getExternalStorageDirectory().getAbsolutePath().replace("/mnt", "") + File.separator; }
From source file:Main.java
public static File createFile(Context context) { File file;// w w w . ja va2 s . c om if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { String timeStamp = String.valueOf(new Date().getTime()); file = new File(Environment.getExternalStorageDirectory() + File.separator + timeStamp + ".jpg"); } else { File cacheDir = context.getCacheDir(); String timeStamp = String.valueOf(new Date().getTime()); file = new File(cacheDir, timeStamp + ".jpg"); } return file; }
From source file:Main.java
/** * Get the application folder on the SD Card. Create it if not present. * @return The application folder./*from www . jav a2 s . c o m*/ */ public static File getApplicationFolder() { File root = Environment.getExternalStorageDirectory(); if (root.canWrite()) { File folder = new File(root, APPLICATION_FOLDER); if (!folder.exists()) { folder.mkdir(); } return folder; } else { return null; } }
From source file:Main.java
public static String getLibraryDirectory() { return Environment.getExternalStorageDirectory() + File.separator + "MicDroid" + File.separator + "recordings"; }
From source file:Main.java
/** * //from w ww.j av a2 s .c o m * @param context * @param backupFolder * @param db_name * @return */ public static boolean backupDB(Context context, String backupFolder, String db_name) { boolean result = false; try { String current_date = DateToString(GetToday(), "dd-MM-yyyy"); File data = Environment.getDataDirectory(); File sdcard = new File(Environment.getExternalStorageDirectory(), backupFolder + "/"); sdcard.mkdirs(); if (sdcard.canWrite()) { String currentDBPath = "//data//" + context.getPackageName() + "//databases//" + db_name + ""; String backupDBPath = "backup_" + db_name + "_" + current_date + ".db"; File currentDB = new File(data, currentDBPath); File backupDB = new File(sdcard, backupDBPath); if (currentDB.exists()) { InputStream input = new FileInputStream(currentDB); OutputStream output = new FileOutputStream(backupDB); byte[] buffer = new byte[1024]; int length; while ((length = input.read(buffer)) > 0) { output.write(buffer, 0, length); } output.flush(); output.close(); input.close(); result = true; } } } catch (Exception e) { Log.e(TAG, e.getMessage()); } return result; }