Context.openFileOutput : Context « Core Class « Android






Context.openFileOutput

    
import java.io.IOException;
import java.io.OutputStreamWriter;

import android.content.Context;

class Common {
  public static boolean WriteToFile(Context context, String strContent, String fileName) {
    boolean bReturn = true;
    OutputStreamWriter osw = null;

    try {
      // ??????
      osw = new OutputStreamWriter(context.openFileOutput(fileName, context.MODE_PRIVATE));
      osw.write(strContent);
      osw.flush();
    } catch (Exception e) {
      e.printStackTrace();
      bReturn = false;
    } finally {
      try {
        osw.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    return bReturn;
  }
}

   
    
    
    
  








Related examples in the same category

1.Context.MODE_WORLD_READABLE
2.Returns whether the context is running on the android emulator.
3.check Internet for Context
4.add Link
5.performing common form field validation tasks
6.Reads all text from asset with specified path.
7.Context Delete File
8.Context Open file