The second form of Android data storage is internal Storage, which is internal storage.
Memory storage is characterized by the storage of private data, its storage location is in the phone memory, one is the normal file storage, the other is the text or picture in the memory cache.
storage location of internal cache/data/data/package name/files or/data/data/package name/cache
1. Create and write a private file to the internal storage:
Steps:
1) Call the openfileoutput() method and return a FileOutputStream object
2) calling the file stream's write () method, writing the data
3) Close the associated stream
eg
2.read a file from internal storage
Steps:
1) Call the Openinputstream() method and return a FileInputStream object
2) Call the Read () method of the file stream, reading the data
3) Close the associated stream
eg
Note: In Java file storage, we typically pass a similar fileinputstream FIS = new FileInputStream (String name) or fileoutstream fos = new FileOutputStream (file file) or FileOutputStream (), but in Android, the system provides us with two very convenient methods Openfileinputstream (), The Openfileoutputstream () method allows us to store internally.
3. Extension: read the/src/raw file under Android Engineering, use the system-provided Openrawresource() to return a InputStream object, however we cannot perform write operations to the file .
Resources res = getresources ();
Some useful methods provided by the 4.Android system are:
5. The cache directory of text or picture in the interior.
Characteristics:
1) Internal buffer cache directory, the Android system will automatically empty the cache directory files when the phone internal storage is full.
2) The cached directory takes precedence over the memory card for storage, because the space is larger, and if there is no memory card, the internal cache space is used.
3) Android system on the memory card, also created a set of application private cache folder.
4) Context. Getexternalcachedir (),
Get the cache directory of the application private in the memory card
5) Context. Getcachedir (),
Gets the cache directory of the application private in the phone's internal storage.
eg
Open File Explore View:
Export the file to view the content:
Extension: There is a lot of content about the cache, the level three cache, image clipping, sampling, external cache of images, storage, and so on.
not finished, to be continued.
Android data Storage (2): Internal Storage