Chapter 23
Accessing Files
While Android offers structured storage, via preferences and databases, sometimes a simple file will suffice. Android offers two models for accessing files: one for files prepackaged with your application and one for files created on-device by your application. Both of these models are covered in this chapter.
You and the Horse You Rode in On
Let’s suppose you have some static data you want to ship with the application, such as a list of words for a spell checker. The easiest way to deploy that is to place the file in the res/raw directory, so it will be put in the Android application APK file as part of the packaging process as a raw resource.
To access this file, you need to get yourself a Resources
object. From ...
Get Beginning Android 2 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.