List of usage examples for android.content Context getFilesDir
public abstract File getFilesDir();
From source file:Main.java
public static String getFileRoot(Context context) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { File external = context.getExternalFilesDir(null); if (external != null) { return external.getAbsolutePath(); }/*from ww w . j a v a 2s. co m*/ } return context.getFilesDir().getAbsolutePath(); }
From source file:Main.java
private static String getFileRoot(Context context) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { File external = context.getExternalFilesDir(null); if (external != null) { return external.getAbsolutePath(); }/*from w w w.j a v a 2 s.c om*/ } return context.getFilesDir().getAbsolutePath(); }
From source file:Main.java
public static String getRootFolder(@NonNull Context context) { String rootPath = null;//from w w w . j ava 2 s .c o m if (android.os.Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { rootPath = Environment.getExternalStorageDirectory().getAbsolutePath(); } else { rootPath = context.getFilesDir().getAbsolutePath(); } return rootPath; }
From source file:net.naonedbus.utils.InfoDialogUtils.java
/** * Afficher une dialog avec un message, uniquement si elle n'a pas dj t * affiche// www .j av a 2s . c o m * * @param context * @param messageId */ public static void showIfNecessary(final Context context, final int titreId, final int messageId) { final File dataFile = new File(context.getFilesDir(), MESSAGE_FOLDER + File.separator + messageId); createDir(context); if (!dataFile.exists()) { show(context, titreId, messageId); try { dataFile.createNewFile(); } catch (final IOException e) { BugSenseHandler.sendExceptionMessage("Erreur lors de la cration du marqueur", null, e); } } }
From source file:sharedcode.turboeditor.root.RootUtils.java
public static void writeFile(Context context, String path, String text, String encoding, boolean isRoot) throws Exception { File file = new File(path); if (!file.canWrite() && isRoot) { File appFolder = context.getFilesDir(); File tempFile = new File(appFolder, "temp.root.file"); if (!tempFile.exists()) tempFile.createNewFile();/*w w w .j a v a 2s.c om*/ FileUtils.write(tempFile, text, encoding); Shell shell = Shell.startRootShell(); Toolbox tb = new Toolbox(shell); String mount = tb.getFilePermissions(path); tb.copyFile(tempFile.getAbsolutePath(), path, true, false); tb.setFilePermissions(path, mount); tempFile.delete(); } else { FileUtils.write(file, text, encoding); } }
From source file:com.dajodi.scandic.Util.java
public static MemberInfo readMemberInfo(Context context) throws FileNotFoundException { File f = new File(context.getFilesDir(), JSON_FILENAME); if (!f.exists()) { return null; }//from w w w . j a v a 2s .co m Reader reader = new BufferedReader(new FileReader(f)); PersistedData data = new JSONDeserializer<PersistedData>().deserialize(reader, PersistedData.class); return data == null ? null : data.getMemberInfo(); }
From source file:Main.java
public static Process runSuCommandAsync(Context context, String command) throws IOException { DataOutputStream fout = new DataOutputStream(context.openFileOutput(SCRIPT_NAME, 0)); fout.writeBytes(command);/* w w w. ja v a2 s . c om*/ fout.close(); String[] args = new String[] { "su", "-c", ". " + context.getFilesDir().getAbsolutePath() + "/" + SCRIPT_NAME }; Process proc = Runtime.getRuntime().exec(args); return proc; }
From source file:Main.java
/** * Returns application files directory. Files directory will be created on SD card * <i>("/Android/data/[app_package_name]/files")</i> if card is mounted. Else - Android defines files directory on * device's file system./*from w w w. j a v a 2s. c o m*/ * * @param context Application context * @return Files {@link File directory} */ public static File getFilesDirectory(Context context) { File appFilesDir = null; if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { appFilesDir = getExternalFilesDir(context); } if (appFilesDir == null) { appFilesDir = context.getFilesDir(); } return appFilesDir; }
From source file:Main.java
public static File getCpoFilesDir(Context appCtx) { File filesDir;/* ww w .j a va 2 s . c om*/ if (isExternalStorageWritable()) { // We can read and write the media filesDir = appCtx.getExternalFilesDir(null); } else { // Load another directory, probably local memory filesDir = appCtx.getFilesDir(); } return filesDir; }
From source file:pw.thedrhax.util.Logger.java
/** * Log sharing routines/*from w w w . ja v a 2 s . co m*/ */ public static Uri writeToFile(Context context) throws IOException { File log_file = new File(context.getFilesDir(), "pw.thedrhax.mosmetro.txt"); FileWriter writer = new FileWriter(log_file); writer.write(toString(Logger.LEVEL.DEBUG)); writer.flush(); writer.close(); return FileProvider.getUriForFile(context, "pw.thedrhax.mosmetro.provider", log_file); }