Permissions for Android files

Source: Internet
Author: User

Permissions concepts for files
    4 modes of operation for files:
    context.mode_private: Is the default mode of operation, which means that the file is private data, can only be accessed by the application itself, in which the content of the write overwrites the contents of the original file, if you want to append the newly written content to the original file. You can use Context.mode_append

    context.mode_append: Mode checks whether a file exists, appends content to the file, or creates a new file.
    context.mode_world_readable and context.mode_world_writeable are used to control whether other apps have permission to read and write to the file.

    mode_world_readable: Indicates that the current file can be read by another application, Mode_world_writeable: Indicates that the current file can be written by another application.
     If you want the file to be read and written by another app, you can pass in:
      openfileoutput ("Itcast.txt", Context.mode_world_readable +             context.mode_world_writeable);

    android has its own security model, and when the application (. apk) is installed, the system assigns him a userid, which requires a UserID match when the app is going to access other resources such as files. By default, any file created by the app, Sharedpreferences, should be private (in/data/data/<package name>/files) and other programs cannot access it. Unless you specify context.mode_world_readable or context.mode_world_writeable at creation time, only such other programs can access them correctly.

Permissions for Android files

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.