Challenge: Use External Storage

Saving files on internal storage is the right choice for most applications, especially when data privacy is a concern. Some apps, however, might want to write to the device’s external storage if it is available. This can be useful if you are storing data that you want to share with other apps or the user, like music, photos or downloads from the web. External storage is almost always more plentiful, too, which makes it the right choice for large media like videos.

To write to external storage, you need to do two things. First, check to ensure that the external storage is available. The android.os.Environment class has several helpful methods and constants that you can use to determine this. Second, get a handle ...

Get Android Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.