Android File Permission, android File Permission
File Permission Concept
Four file operation modes:
Context. MODE_PRIVATE: the default operation mode. This mode indicates that the file is private data and can only be accessed by the application itself. In this mode, the written content will overwrite the content 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: the mode checks whether the file exists and appends the content to the file if it exists. Otherwise, a new file is created.
Context. MODE_WORLD_READABLE and Context. MODE_WORLD_WRITEABLE are used to control whether other applications have the permission to read and write the file.
MODE_WORLD_READABLE: indicates that the current file can be read by other applications; MODE_WORLD_WRITEABLE: indicates that the current file can be written by other applications.
If you want the file to be read and written by other applications, you can pass in:
OpenFileOutput ("itcast.txt", Context. MODE_WORLD_READABLE + Context. MODE_WORLD_WRITEABLE );
Androidhas a set of security models. When the application program (.apk) is installed, the system will assign a userid to it. When the application wants to access other resources, such as files, it needs to match the userid. By default, files created by any application, sharedpreferences, and databases, should be private (in/data/<package name>/files), and cannot be accessed by other programs. Unless Context. MODE_WORLD_READABLE or Context. MODE_WORLD_WRITEABLE is specified during creation, only other programs can access it correctly.