Android file read/write api and android read/write api

Source: Internet
Author: User

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 ();



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.