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 ();
}
}
}