O'Reilly logo

Android Recipes: A Problem-Solution Approach, Third Edition by Jeff Friesen, Dave Smith

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

6-10. Sharing Your SharedPreferences

Problem

You would like your application to provide the settings values it has stored in SharedPreferences to other applications of the system and even to allow those applications to modify those settings if they have permission to do so.

Solution

(API Level 1)

Create a ContentProvider to interface your application’s SharedPreferences to the rest of the system. The settings data will be delivered using a MatrixCursor, which is an implementation that can be used for data that does not reside in a database. The ContentProvider will be protected by separate permissions to read/write the data within so that only permitted applications will have access.

How It Works

To properly demonstrate the permissions ...

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