Android file read/write API

Source: Internet
Author: User



1.android four read and write file modes

Context.mode_private: Private mode, overwrite original file contents

Context.mode_append: Append mode, appended to the original file content

Context.mode_world_readable: Ability to read content from other applications

Context.mode_world_writeable: Ability to write content to other applications

If you want other apps to read and write, add 2 context.mode_world_readable + context.mode_world_writeable

FileOutputStream OS = Context.openfileoutput (fileName, module);
Os.write (Content.getbytes ());
Os.close ();


2. Append when other apps write to data


String Path = "/data/data/com.example.demo1/files/rw.txt";
The second parameter, the output stream, is filled in by appending.
FileOutputStream fos = new FileOutputStream (new File (path), true);
Fos.write ("ddddddddd". GetBytes ());
Fos.flush ();
Fos.close ();



Android file read/write API

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.