Private mode of operation:
1. Can only be accessed by the app that created this file
2. If the file does not exist, it will create the file, if it exists, it will overwrite the original file.
3, Context.mode_private
public void Save (string filename, string content) throws Exception {//Private mode of operation: The file created can only be accessed by the app and cannot be accessed by other apps. In addition, a file created with private operation mode overwrites the contents of the source file with the contents of the FileOutputStream OutStream = Context.openfileoutput (filename,context.mode_ PRIVATE); Open output Stream Outstream.write (Content.getbytes ()) with private operation mode; Outstream.close ();}
Append mode:
1, private, can only be accessed by the application that created this file
2, if the file does not exist, it will create a file, if the file already exists, it will overwrite the original file
3, Context.mode_append;
public void Saveappend (string filename, string content) throws Exception {FileOutputStream OutStream = Context.openfileou Tput (Filename,context.mode_append); Outstream.write (Content.getbytes ()); Outstream.close ();}
readable mode:
1. Files created can be read by other applications
2, context.mode_world_readable;
public void savereadable (string filename, string content) throws Exception {FileOutputStream OutStream = Context.openfile Output (filename,context.mode_world_readable); Outstream.write (Content.getbytes ()); Outstream.close ();}
Writable mode:
1. Files created can be written by other applications
2, Context.mode_world_readable
public void savewriteable (string filename, string content) throws Exception {FileOutputStream OutStream = Context.openfil Eoutput (filename,context.mode_world_writeable); Outstream.write (Content.getbytes ()); OutStream.close ();}
both written and readable blending modes:
1. Allow other applications to read and write, and overwrite : context.mode_world_readable+context.mode_world_writeable
public void savewriteable (string filename, string content) throws Exception {FileOutputStream OutStream = Context.openfil Eoutput (filename,context.mode_world_readable+context.mode_world_writeable); Outstream.write (Content.getbytes ()); Outstream.close ();}
2.allow other applications to read and write, and append: context.mode_append+context.mode_world_readable+context.mode_world_writeable
public void savewriteable (string filename, string content) throws Exception {FileOutputStream OutStream = Context.openfil Eoutput (filename,context.mode_append+context.mode_world_readable+context.mode_world_writeable); Outstream.write (Content.getbytes ()); Outstream.close ();}
Android Development Series (VI): Operating mode of files in Android apps