sharedpreferences

Read SharedPreferences when you haven't set the name of the file.

When you createa a PreferenceScreen on Android, your application creates a default SharedPreferences file for the settings. I want to read this name, or get a reference without specifing the name. Currently I use: SharedPreferences prefs = ctx.getSharedPreferences("prefs", 0); SharedPreferences.Editor ed=prefs.edit(); But this return...

ListPreference, how can you make it to NOT save to SharedPreference?

I am resuing ListPreference for a setting which I store in the database. I do not want it stored in the preference file. How can I reuse ListPreference in such way that it does NOT save to SharedPreference file? ...

Using the LIMIT statement in a SQLite query

Hi guys. I have a query that selects rows in a ListView without having a limit. But now that i have implemented a SharedPreferences that the user can select how much rows will be displayed in the ListView, my SQLite query doesnt work. Im passing the argument this way: return wDb.query(TABELANOME, new String[] {IDTIT, TAREFATIT, SUMARIO...

How do I get the SharedPreferences from a PreferenceActivity in Android?

Hi, I am using a PreferenceActivity to show some settings for my application. I am inflating the settings via a xml file so that my onCreate (and complete class methods) looks like this: public class FooActivity extends PreferenceActivity { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); addPreferencesFr...

Why is my onSharedPreferenceChangeListener being called multiple times when I change a pref.

I've written an app with 3 tabs. Each tab has the same list view with different data sources. I have setup SharedPreferences in the tabhost activity, but I put my onSharedPreferenceChangeListener method in my listactivity. When I change a preference, my listener gets called and it updates my database. This is all working. However, i...

How do I get preferences to work in Android?

I've really been struggling through this. New to Java/Android. I'm writing my first app and this is the first thing that has taken me longer than a couple days of searching to figure out. Here's the setup: It's a BAC calculator / drink counter: A formula is used to calculate the BAC. Here's the forumla: Bac = ((StandardDrinks / 2) * ...

Android ==> Preference ???

my app crashes with a null pointer exception on the code below. i have an xml preference file under res/xml/defaults.xml Any idea why it's crashing? public class Preference extends Activity { public Preference() { } public String getPreference(String key) { //it still crashes here SharedP...

Getting java.lang.nullPointerException using SharedPreferences

I am trying to save the date of file parsing, so that when next time user, opens the application, the date can be checked against the last parsing date. I am using shared preference to save the data and retrieve it, but getting error. here is the code : SharedPreferences settings = getPreferences(0); String today = new Date(System.cur...

User preferences file vs App preferences file

My android application has two kinds of preferences: 1) I have user preferences defined in res/xml/preferences.xml so that users can manage their preferences with a PreferenceActivity. 2) I'd like to define another file for global configuration preferences of my app. What is the best way to manage my app config preferences? Should I c...

Android SharedPreferences limitations?

I developed a game on Android. I am currently saving most of the game stats in a Database. However the app does not utilize more than a single row in the DB. I am now interested in introducing some new stats but this will cause my DB to re-install and thus clear out everyone's progress. In order to avoid this in the future I am consideri...

Android -- SQLite + SharedPreferences, 2 Threads Simultaneous Read/Write?

Hello, I have two parts of a program (the actual app and a BroadcastReceiver) that could possibly try to connect to and modify a SQLite database and a SharedPreferences file. 1) I know you can make multiple connections to a single SQLite database. I also read that SQLite can "lock" the database when it attempts to modify or read from a...

Android Saving Edittext content to SharedPreferences and Reading it back

In my xml i have an edittext element like this <EditText android:id="@+id/hrvalue" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="64" android:textSize="18sp"> </EditText> in my configuration class i want to read the value of the edittext and save it to a variable. In the edittext box the user wi...

sharedUserId: safe to change when app is already in market?

For the next version of our application, I want to change the sharedUserId since we now use an internal control dashboard app which must write to the other app's settings files. But since the app is already installed on many phones, will this be a problem? I ran a little test on the emulator, and I'm seeing exceptions in the device logs...

How can I add registerOnSharedPreferenceChangeListener on to a ListActivity?

When I call intent public class TInfo extends ListActivity implements OnSharedPreferenceChangeListener{ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); prefs = PreferenceManager.getDefaultSharedPreferences(this); initvars(); setListAdapter(new TAdapter()); // class TAdapter extends ArrayAd...

Android PreferenceManager without visual component?

I am trying to get a SharedPreferences object from the PreferenceManager but don't want to pass in the Context to the class. Can I get a "global" context from inside my class? SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(Some Global Context); ...

Use PreferenceActivity and save preferences in ContentProvider, how?

Hello, Jeff Sharkey in this post (http://goo.gl/G3wt) shows how to create save application preferences in database by hack on PreferenceActivity. It said i can use a ContentProvider, too. Can you give me an example on how to save preferences from PreferenceActivity to ContentProvider? thanks ...

Loading in preferences only on ititial launch or user has just visited PreferenceActivity

I'm working on a live wallpaper and I would like to load in my shared_preferences file only when the wallpaper is first set or when the user visits my PreferenceActivty. I'm currently loading in my preferences in onVisibilityChanged() of my WallpaperEngine() class. Is there a place that makes more sense? The reason I don't want to loa...

Android - View setText from SharedPreference Value using XML

Hello, I've chosen the path to have each Activity implement a onSharedPreferenceChangedListener. In order for a service to update values to be sent back to several Activities at once (it doesn't care which one has the focus) When the Listener is called, I only have the key. I then have to perform a lookup of that key to get the corresp...

Getting SharedPreference From XML

Hello, I am having problems finding a way to populate a TextView with the value of a SharedPreference using XML. Is there a way to reference the preference like a string resource. Something like TextView android:text="@preference/name" ...

Dealing with shared preferences stored in a library

I have an app that has a free, and a paid version. I put all the free version code into a library, which I reference from a new free version project, and the paid version project. I noticed that the library, and now my projects all have a properties file, and my preferences stopped working completely. It seems that depending on what na...