Android saves and reads data to files

Source: Internet
Author: User

Android saves and reads data to files

Android gets fileoutputstream

Context. openfileoutput (file, permission)

Context is the context of the environment, and activity inherits the ccontext class.For exampleAA inherits Activity
You can write it like this.: AA. This. openfileoutput (file, permission)

File: Name and extension of the file created for the user, such as water.txt

Permission: Android has four Permissions

1. Context. mode_private

Private Attribute, accessible only by yourself, and the content written for the second time will overwrite the content written for the first time

2. Context. mode_append

Private Attribute, accessible only by yourself. The content written for the second time will be appended to the end of the content written for the first time.

3. Context. mode_world_writeable

Public attributes can be written to other projects, but the content written for the second time will overwrite the content written for the first time.

4. Context. mode_world_readable

Public attributes, which can be read by other projects

Permissions can be added, for example

Now I want another project to read, write, and append.

Context. mode_world_readable + context. mode_world_writeable + context. mode_append

Files created by Android are stored in/data/package name/files on the mobile phone.

 

Android gets fileinputstream

Context. openinfileoutput (file)

Context is the context of the environment, and activity inherits the context class.

File: Name and extension of the file created for the user, such as water.txt

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.