You can store files directly on the mobile device or on a removable storage medium. By default, other applications cannot access these files.

To read data from a file, call Context.openFileInputf) and pass it the local name and path of the file. It returns a standard Java FilelnputStream object. To write to a file, call Context.openFileOutputf) with the name and path. It returns a FileOutputStream object. Calling these methods with name and path strings from another application will not work; you can only access local files.

If you have a static file to package with your application at compile time, you can save the file in your project in res/raw/myDataFile, and then open it with Resources.openRawResource fR.raw.myDataFile). It returns an InputStream object that you can use to read from the file.

0 0

Post a comment