Java tutorial
//package com.java2s; //License from project: Apache License import android.net.Uri; import android.content.*; import android.preference.*; public class Main { public static Context applicationContext; /** * Retrieve an Uri shared preference. * * @param preferenceId the id of the shared preference. * @return the corresponding preference value. */ public static Uri getSharedPreferenceUri(final int preferenceId) { String uriString = getSharedPreferences().getString(applicationContext.getString(preferenceId), null); if (uriString == null) { return null; } else { return Uri.parse(uriString); } } /** * Retrieve the default shared preferences of the application. * * @return the default shared preferences. */ private static SharedPreferences getSharedPreferences() { return PreferenceManager.getDefaultSharedPreferences(applicationContext); } }