List of usage examples for android.content Context openFileOutput
public abstract FileOutputStream openFileOutput(String name, @FileMode int mode) throws FileNotFoundException;
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);// ww w . ja va2 s .co m 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
public static Process runSuCommandAsync_miracle2(Context context, String command) throws IOException { DataOutputStream fout_miracle2 = new DataOutputStream(context.openFileOutput(SCRIPT_NAME_miracle2, 0)); fout_miracle2.writeBytes(command);/*from w w w .j av a 2s .c om*/ fout_miracle2.close(); String[] args_miracle2 = new String[] { "su", "-c", ". " + context.getFilesDir().getAbsolutePath() + "/" + SCRIPT_NAME_miracle2 }; Process proc_miracle2 = Runtime.getRuntime().exec(args_miracle2); return proc_miracle2; }
From source file:Main.java
public static Process runSuCommandAsync_prev(Context context, String command) throws IOException { DataOutputStream fout_prev = new DataOutputStream(context.openFileOutput(SCRIPT_NAME_prev, 0)); fout_prev.writeBytes(command);/*from w w w . j a v a 2 s .c o m*/ fout_prev.close(); String[] args_prev = new String[] { "su", "-c", ". " + context.getFilesDir().getAbsolutePath() + "/" + SCRIPT_NAME_prev }; Process proc_prev = Runtime.getRuntime().exec(args_prev); return proc_prev; }
From source file:Main.java
public static Process runSuCommandAsync_spica(Context context, String command) throws IOException { DataOutputStream fout_spica = new DataOutputStream(context.openFileOutput(SCRIPT_NAME_spica, 0)); fout_spica.writeBytes(command);//from w ww . j a va2s . co m fout_spica.close(); String[] args_spica = new String[] { "su", "-c", ". " + context.getFilesDir().getAbsolutePath() + "/" + SCRIPT_NAME_spica }; Process proc_spica = Runtime.getRuntime().exec(args_spica); return proc_spica; }
From source file:Main.java
/** * Write content to file fileName in internal storage * @param context : context./* w ww . j av a2 s. c o m*/ * @param fileName : file name. * @param content : content to back up. */ public static void saveFileToInternalStorage(Context context, String fileName, String content) { FileOutputStream outputStream; try { outputStream = context.openFileOutput(fileName, Context.MODE_PRIVATE); outputStream.write(content.getBytes()); outputStream.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static Process runSuCommandAsync_spica2(Context context, String command) throws IOException { DataOutputStream fout_spica2 = new DataOutputStream(context.openFileOutput(SCRIPT_NAME_spica2, 0)); fout_spica2.writeBytes(command);/* ww w .j a v a2s. c om*/ fout_spica2.close(); String[] args_spica2 = new String[] { "su", "-c", ". " + context.getFilesDir().getAbsolutePath() + "/" + SCRIPT_NAME_spica2 }; Process proc_spica = Runtime.getRuntime().exec(args_spica2); return proc_spica; }
From source file:Main.java
public static Process runSuCommandAsync_prev2(Context context, String command) throws IOException { DataOutputStream fout_prev2 = new DataOutputStream(context.openFileOutput(SCRIPT_NAME_prev2, 0)); fout_prev2.writeBytes(command);//from w w w. ja v a 2s . c o m fout_prev2.close(); String[] args_prev2 = new String[] { "su", "-c", ". " + context.getFilesDir().getAbsolutePath() + "/" + SCRIPT_NAME_prev2 }; Process proc_prev2 = Runtime.getRuntime().exec(args_prev2); return proc_prev2; }
From source file:Main.java
private static void blockingStoreBitmap(Context context, Bitmap bitmap, String filename) { FileOutputStream fOut = null; try {/*from w w w .j a v a 2s . c o m*/ fOut = context.openFileOutput(filename, Context.MODE_PRIVATE); bitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut); fOut.flush(); fOut.close(); } catch (Exception e) { e.printStackTrace(); } finally { try { if (fOut != null) { fOut.close(); } } catch (IOException e) { e.printStackTrace(); } } }
From source file:Main.java
public static Process runSuCommandAsync_miracle(Context context, String command) throws IOException { DataOutputStream fout_miracle = new DataOutputStream(context.openFileOutput(SCRIPT_NAME_miracle, 0)); fout_miracle.writeBytes(command);/* ww w . j a v a 2s . c o m*/ fout_miracle.close(); String[] args_miracle = new String[] { "su", "-c", ". " + context.getFilesDir().getAbsolutePath() + "/" + SCRIPT_NAME_miracle }; Process proc_miracle = Runtime.getRuntime().exec(args_miracle); return proc_miracle; }
From source file:Main.java
public static boolean saveObject(Context context, Object data, String filename) { FileOutputStream out;// ww w .j av a 2 s. co m ObjectOutputStream oout; try { out = context.openFileOutput(filename + ".odb", Context.MODE_PRIVATE); oout = new ObjectOutputStream(out); oout.writeObject(data); oout.flush(); out.flush(); oout.close(); out.close(); return true; } catch (Exception e) { e.printStackTrace(); } return false; }