Working with internal storage
This is an available storage medium on the Android application framework that empowers developers to store private data on a device's memory. As the word private implies, other applications cannot access the data stored by an app via internal storage. In addition, these files will be removed from storage when that app is uninstalled.
Writing files to internal storage
In order to create a private file on internal storage, it is necessary to call openFileOutput()
. The openFileOutput()
function takes two arguments. The first is the name (in form of a String
) of the file to open and the second is the operating mode. Note that openFileOutput()
must be called within an instance of Context
, such as an Activity
.
The openFileOutput()
method returns a FileOutputStream
. This can then be used to tell the file it is done with the write()
method. Once writing is done, the FileOutputStream
should be closed by calling its close()
method. The following code snippet demonstrates...