Android Learning Note 46--file Storage

Source: Internet
Author: User

File Store--io operation files

Openfileoutput, Openfileinput

The context provides the following two ways to open the file IO stream inside the data folder of this application.

1.FileInputStream openfileinput (String name): Opens the name file under the Data folder in the application corresponding to the input stream

2.FileOutputStream openfileoutput (String name,int mode): Open the output stream corresponding to the name file under the application's data file

Attention:

The mode parameter in FileOutputStream openfileoutput (String name,int mode) is used to specify the pattern of open files, supported by the following modes:

1.mode_private: Changes to the file can only be read and written by the current program;

2.mode_append: Opens the file in an additional way, and the application can append the content to the file;

3.mode_world_readable: The contents of the file can be read by other programs (read only);

4.mode_world_writeable: The contents of the file can be read and written by no other program;

In addition, the context also provides the following two ways to access the application's Data folder.

1.getDir (String name,int mode): Gets or creates a subdirectory of name in the application's Data folder;

2.File Getfilesdir (): Gets the absolute path of the data folder for the application;

3.string[] FileList (): Returns all files under the Data folder of the application;

4.deleteFile (String): Deletes the file specified under the Data folder of the application;

Examples are as follows:

Android Learning Note 46--file Storage

Related Article

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.