Android in all sets has its own security model. For details, see Android development documentation.
.. When the application program (.apk) is installed, a userid is assigned. When the application wants to access other resources, such as files, userid matching is required. By default, files, databases, and sharedpreferences created by any application should be private (in/data/your_project/files/) and cannot be accessed by other programs. Unless mode_world_readable or mode_world_writeable is specified during creation, the other programs can be accessed correctly only in this way.
Because of this security guarantee, Android requires that the user ID of the process be checked when the process opens the file. Therefore, Java APIs cannot be used directly to open it, Because Java Io functions do not mention this mechanism.
// You cannot open the program directly using Java APIs.Private Data
The default path is/data/your_project/files/
Filereader file = new filereader ("android.txt ");
Private Data is particularly emphasized here! The implication is that if a file or data is not private to the program, and you do not need to go through the android permission check when accessing it, you can still directly access it using Java I/O APIs. The so-called non-private data is only files or data stored on sdcard,
// You can use Java I/O APIs to directly open files on sdcard.
Filereader file = new filereader ("/sdcard/android.txt ");
To open your own private files and data, you must use the openfileoutput and openfileinput methods provided by activity.
// Create a private file of the program. Due to permission requirements, you must use the method provided by activity.
Fileoutputstream OS = This. openfileoutput ("android.txt", mode_private );
Outputstreamwriter outwriter = new outputstreamwriter (OS );
// Read private files of the program. The method provided by activity must be used due to permission requirements.
Fileinputstream OS = This. openfileinput ("android.txt ");
Inputstreamreader inreader = new inputstreamreader (OS );