sharedpreferences

Is there another class in android that can replace the activity call throught which I can access SharedPreferences?

I'm have a User Class in my Android application that pulls out information from SharedPreferences I find myself instantiating the class within an Android Activity User currentUser = new User(this); I then go on to use the context to get the preferences. userName = context.getSharedPreferences("UserName", Context.MODE_PRIVATE); I ha...

Android 2.2 Data Backup: How to backup DefaultSharedPreferences?

I am implementing the new BackupAgentHelper from android 2.2. For it to work you need to supply the name of the SharedPreferences that you want to backup: public class MyPrefsBackupAgent extends BackupAgentHelper { // The name of the SharedPreferences file static final String PREFS = "user_preferences"; // A key to uniquely identify t...

Android: How to use Buttons in Preference Screen

I'd like to provide a Button in the PreferenceActivity. The user should be able to set a time (e.g. via TimePicker), but there's no ButtonPreference or something like that. I don't want to use EditTextPreference. So do I have to use a default Button in the PreferenceActivity and save the settings for it manually? Regards, cody ...

Android: How to get the time from a TimePicker when it is typed in

I've got a DialogPreference which implements a simple TimePicker.OnTimeChangedListener (see below). Setting the time by clicking the +/- buttons works great. But I don't know how to save the state of the timepicker when the user typed in the time directly into the textfield. It could be sufficient to access to the current textfield value...

How do I create a class specifically for the purpose of using SharedPreferences?

I have a couple activities in my app that I would like to utilize shared preferences. Initially, I created a method in each activity to utilize SharedPreferences, which worked fine. However, since there are multiple activities that use the same data, I’m basically tucking similar methods in multiple places. So it seemed like it made m...

Android: using SharedPreferences in a library

I made a library that I use across my app. I want it to access some settings that are stored in the shared preferences. This is a shortened version of my library: package com.android.foobar; import android.content.SharedPreferences; import android.preference.PreferenceManager; public class Lib { int now; public Lib() { ...

How to use SharedPreferences as LocalStore, in more generic way?

Being new in Android world and advancing with joy day by day ;) I would like to share examples about common usage. Here comes example about using SharedPreferences with generic LocalStore class. create a common class to be used by your main activity or by any of sub-activity. public class LocalStore { private static final...