Android file read/write api and android read/write api
1. Four file read/write modes for android
Context. MODE_PRIVATE: Private mode, covering the original file content
Context. MODE_APPEND: append mode, which is added after the original file content
Context. MODE_WORLD_READABLE: content that can be read by other applications
Context. MODE_WORLD_WRITEABLE: content that can be written by other applications
To read and write data to other applications, add Context. MODE_WORLD_READABLE + Context. MODE_WORLD_WRITEABLE.
FileOutputStream OS = context. openFileOutput (fileName, module );
OS. write (content. getBytes ());
OS. close ();
2. If you want other applications to write data, the append method is added.
String path = "/data/com. example. demo1/files/rw.txt ";
// The second parameter indicates the output stream, which is appended.
FileOutputStream fos = new FileOutputStream (new File (path), true );
Fos. write ("ddddddddd". getBytes ());
Fos. flush ();
Fos. close ();