Saving and reading files in the internal storage
original source : http://www.lucazanini.eu/en/2016/android/saving-reading-files-internal-storage/
You can save and read files in the internal storage as private files which only your app can see except for other apps with root privileges.
The absolute path of this folder is datadata[your app package]files
The class Context provides some methods which help you to make operations such as:
openFileInput(String name)
Open a private file associated with this Context’s application package for readingopenFileOutput(String name, int mode)
Open a private file associated with this Context’s application package for writinggetFilesDir()
Gets the absolute path to the filesystem directory where your internal files are savedgetDir()
Creates (or opens an existing) directory within your internal storage spacedeleteFile()
Deletes a file saved on the internal storagefileList()
Returns an array of files currently saved by your application
and you don’t need to have special permissions in order to use these methods.
For example the following code taken from Using the Internal Storagecreates a file containing the string “hello world!”

where at the line 5, in place of MODE_PRIVATE you can use MODE_APPEND, other constants such as MODE_WORLD_READABLE and MODE_WORLD_WRITEABLE are deprecated.
The following code reads the same file and shows a message with the text “hello world!”

But these examples have a limitation: they can’t be used in sub folders, in other words you can’t create a tree structure of directories and files.
If you need to create files in subdirectories you must use the standard technique of java, for example the following code creates a file inside the folder “sub”

and the following code reads the same file
