O'Reilly logo

Beginning Android 2 by Mark L. Murphy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required