List of usage examples for android.content Context getExternalFilesDir
@Nullable public abstract File getExternalFilesDir(@Nullable String type);
From source file:Main.java
public static File copyAssets(Context context, String fileName) { AssetManager assetManager = context.getAssets(); File outFile = null;/* ww w . j a v a2 s . co m*/ InputStream in = null; OutputStream out = null; try { in = assetManager.open(fileName); // copy file path outFile = new File(context.getExternalFilesDir(null), fileName); out = new FileOutputStream(outFile); copyFile(in, out); } catch (IOException e) { Log.e("tag", "Failed to copy asset file: " + fileName, e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { // NOOP } } if (out != null) { try { out.close(); } catch (IOException e) { // NOOP } } } return outFile; }
From source file:io.nuclei.splice.internal.FileManager.java
private static File getBaseFile(Context context, int type) throws IOException { File base = null;//from w w w .j a v a2 s . c o m if (type == TYPE_EXTERNAL_FILE && Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) base = new File(context.getExternalFilesDir(null), DIR); else if (type == TYPE_CACHE_FILE) base = new File(context.getCacheDir(), DIR); else if (type == TYPE_LOCAL_FILE) base = new File(context.getFilesDir(), DIR); if (base == null) throw new IOException("Couldn't access directory type: " + type); if (!base.exists() && !base.mkdirs()) throw new IOException("Couldn't create directory: " + base); return base; }
From source file:com.secupwn.aimsicd.utils.RequestTask.java
/** * The folder path to OCDB download.//ww w. j a v a2s .c o m * @param context * @return */ public static String getOCDBDownloadDirectoryPath(Context context) { return (context.getExternalFilesDir(null) + File.separator) + "OpenCellID/"; }
From source file:com.cyberocw.habittodosecretary.file.StorageHelper.java
public static File getAttachmentDir(Context mContext) { return mContext.getExternalFilesDir(null); }
From source file:com.cyberocw.habittodosecretary.file.StorageHelper.java
public static File getAttachmentDir(Context mContext, String dir) { return mContext.getExternalFilesDir(dir); }
From source file:com.cyberocw.habittodosecretary.file.StorageHelper.java
/** * Retrieves the folderwhere to store data to sync notes * * @param mContext/*from www . jav a 2 s .c o m*/ * @return */ public static File getDbSyncDir(Context mContext) { File extFilesDir = mContext.getExternalFilesDir(null); File dbSyncDir = new File(extFilesDir, Constants.APP_STORAGE_DIRECTORY_SB_SYNC); dbSyncDir.mkdirs(); if (dbSyncDir.exists() && dbSyncDir.isDirectory()) { return dbSyncDir; } else { return null; } }
From source file:Utils.GenericUtils.java
public static String readFileFromAppDir(Context context, String fileName) { if (!bFilePath) { dirFile = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES); bFilePath = true;//from w w w.j a v a 2 s . c o m } if (dirFile != null) { try { File downloadDir = new File(dirFile, fileName); fileName = downloadDir.getCanonicalPath(); } catch (Exception e) { Log.e("readFile", e.getMessage()); fileName = null; } } return fileName; }
From source file:Utils.GenericUtils.java
public static File saveFileToAppDir(Context context, String dirType, String fileName, String data) { File downloadDir = new File(context.getExternalFilesDir(dirType), ""); if (!downloadDir.exists() && !downloadDir.mkdirs()) { Log.e("UTILS", "saveFileToAppDir: Directory not created"); }/*from w ww. j a v a 2 s.c om*/ File file = new File(context.getExternalFilesDir(dirType), fileName); try { FileOutputStream myOutput = new FileOutputStream(file); myOutput.write(data.getBytes()); myOutput.close(); } catch (IOException e) { Log.e("UTILS", e.getMessage()); } return file; }
From source file:com.cyberocw.habittodosecretary.file.StorageHelper.java
public static File createNewAttachmentFile(Context mContext, String extension) { File f = null;/*from w w w .j a v a 2s . co m*/ if (checkStorage()) { f = new File(mContext.getExternalFilesDir(null), createNewAttachmentName(extension)); } return f; }
From source file:com.cyberocw.habittodosecretary.file.StorageHelper.java
public static File createNewAttachmentFile(Context mContext, String folder, String extension) { File f = null;//from w w w . j a va2 s . c o m if (checkStorage()) { f = new File(mContext.getExternalFilesDir(folder), createNewAttachmentName(extension)); } return f; }