Chapter 11. File Management
WHAT'S IN THIS CHAPTER?
Exploring File I/O in Android and iOS
Identifying the I/O differences between Android and iOS
Read and write files
A critical part of any native OS application, whether on the desktop or on a mobile device, is the ability to read and write files and work with the local file system. This chapter introduces you to working with files and directories in your Android or iOS application. It shows you the
File object and what you can use it for in Android/iOS, such as performing standard file operations. The chapter then discusses how to read and write data to a file by creating a plain vanilla text editor.
UNDERSTANDING THE ANDROID FILE AND DIRECTORY STRUCTURE
When you work with files in your Android app, you can access files and directories on both internal and external storage (such as an SD [Secure Digital] card). For internal storage, there are several system directories (such as
/acct, /dev, or
/etc) that you normally do not have to concern yourself with. However, when your application is installed onto the device, it is installed into the
/data/data directory by default. Your application storage and temporary storage are there as well.
Every Android device also supports external storage that your app and potentially other apps can read. In addition, users may copy files from an external storage medium to a desktop computer.
Beyond application-specific directories that you may want to add to external storage, you can use public directories ...