FileIO with Android

suggest change




Reading and writing files in Android are not different from reading and writing files in standard Java. Same package can be used. However, there is some specific related to the folders where you are allowed to write, permissions in general and MTP work arounds.


Android provides means for sharing the file between multiple applications as documented here. This is not required if there is only one app that creates and uses the file.

Android provides alternative storage options like shared and private preferences, saved bundles and built-in database. In some cases, they are better choice than just using plain files.

Android activity does have few specific methods that look like replacements of the Java standard File IO methods. For instance, instead for File.delete() you can call Context.deleteFile(), and instead of applying File.listFiles() recursively you can call Context.fileList() to get the list of all your app specific files with somewhat less code. However, they do not provide extra functionality beyond standard package.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents