Android file access permission

Source: Internet
Author: User

Android file access permission
File Access permission

The file access permission control of Android is the same as that of linux.

File Access permission: Who can access this file. Using drwxrwxrwx is a character control.

First letter

D: folder

-: Indicates a file.

Each of the following three letters is divided into one group.

Group 1: rwx is the object owner's permission

R: read, read

W: write, write

X: execute, run

-: Indicates you do not have the permission.

Group 2: rwx indicates the permissions of users in the same group as the file owner on the file.

R: read, read

W: write, write

X: execute, run

-: Indicates you do not have the permission.

Group 3: rwx indicates the permissions of other users on files

R: read, read

W: write, write

X: execute, run

-: Indicates you do not have the permission.

The first group of permissions is the permissions of the owner.

Any application is another user for other applications.

By default, the file creator has read and write permissions, and no other user has any permissions.
MicrosoftInternetExplorer402DocumentNotSpecified7.8 LB Normal0

Package com. test. storage;

 

Import java. io. FileNotFoundException;

 

Import android. app. Activity;

Import android. OS. Bundle;

Import android. view. View;

 

Public class CreateFileDemo extends Activity {

@ Override

Protected void onCreate (Bundle savedInstanceState ){

// TODO Auto-generated method stub

Super. onCreate (savedInstanceState );

SetContentView (R. layout. activity_main );

}

 

Public void click (View v ){

// The default path is data/application package name/files/which cannot be changed.

/* First parameter, file name

* The second parameter MODE_PRIVATE indicates that the file is private and cannot be modified by others. The previous content will be overwritten when the file is written again,

* MODE_APPEND indicates that the file is private and cannot be modified by others. When the file is written again, It is appended to the previously written file,

* MODE_WORLD_READABLE is used to control whether other applications have the permission to read and write the file, indicating that the current file can be read by other applications.

* MODE_WORLD_WRITEABLE is used to control whether other applications have the permission to read and write the file, indicating that the current file can be written by other applications.

* Multiple modes can be used | connected

*/

Try {

OpenFileOutput ("aaa.txt", MODE_WORLD_READABLE );

} Catch (FileNotFoundException e ){

E. printStackTrace ();

}

 

}
}

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.