Summary of implementation methods of Android reading file content
Android read file content implementation methods, here are several methods, you need to see@ H_ 419_ 1@
If you want to open the application private file stored in / data / data / < package name > / files directory, you can use the openfileinput () method provided by activity@ H_ 419_ 1@
FileInputStream inStream = this. getContext(). openFileInput("itcast.txt"); Log. i("FileTest",readInStream(inStream)); @ H_ 419_ 1@
For the method of readinstream(), see the notes at the bottom of this page@ H_ 419_ 1@
Or use the absolute path of the file directly: @ h_ 419_ 1@
Note: "CN. Itcast. Action" in the file path above is the package of the application. When you write code, you should replace it with the package used by your own application@ H_ 419_ 1@
Private files can only be accessed by the application that created the file. If you want the file to be read and written by other applications, you can specify @ h when creating the file_ 419_ 1@
Context. MODE_ WORLD_ Readable and context MODE_ WORLD_ Writeable permission@ H_ 419_ 1@
Activity also provides getcachedir() and getfilesdir() methods: @ h_ 419_ 1@
The getcachedir() method is used to obtain the / data / data / < package name > / cache directory. The getfilesdir() method is used to obtain the / data / data / < package name > / files directory @ H_ 419_ 1@
Thank you for reading, hope to help you, thank you for your support to this site@ H_ 419_ 1@