The java.util.prefs package provides a way for applications to store and retrieve user and system preference and configuration data.
Questions tagged [preferences]
1531 questions
14
votes
1 answer
does caching values of SharedPreferences make sense?
In my current Android app I have several settings stored in SharedPreferences and one object which handles access to them. I now wonder if it makes sense to cache the values or if doesn't mater much accessing them like:
public final boolean…

Tobias
- 7,282
- 6
- 63
- 85
14
votes
5 answers
Safest way to use SharedPreferences
I need a class which handles my SharedPreferences and I came up with 3 ways of doing it, however after some research it seems most of them are considered "anti-patterns".
Type 1
public final class MyPrefs {
private MyPrefs(){ throw new…

Linxy
- 2,525
- 3
- 22
- 37
13
votes
3 answers
Open EditTextPreference through code (programmatically)
I have made the EditTextPreference 'textPasscode' dependant on a CheckBoxPreference 'checkBoxPasscode'. I want the 'textPasscode' to open up as soon as the user checks the check box.. Is it even possible?
If it is, what can I use in the…

Ayrton Senna
- 3,735
- 5
- 34
- 52
13
votes
1 answer
Is there a good way to persist printer settings in a Swing app?
We are using the new Java printing API which uses PrinterJob.printDialog(attributes) to display the dialog to the user.
Wanting to save the user's settings for the next time, I wanted to do this:
PrintRequestAttributeSet attributes =…

Hakanai
- 12,010
- 10
- 62
- 132
13
votes
2 answers
Cursor type in Emacs
What do I put in my .emacs file to change the cursor type for all frames to box?

Chetan
- 46,743
- 31
- 106
- 145
13
votes
1 answer
Reading and Writing from/to Java Preferences fails on fresh Windows 8,
I have a Java application that reads from the Preferences by using:
Preferences prefs = Preferences.userNodeForPackage(MyClass.class);
prefs.get((String)key, "");
On a fresh Windows 8 machine this fails with:
WARNING: Could not open/create prefs…

Emily L.
- 5,673
- 2
- 40
- 60
13
votes
1 answer
Java How do you use the preference API? Where do these variables store?
Say I have the following
Preferences prefs = Preferences.userRoot().node(this.getClass().getName());
String ID1 = "Test1";
System.out.println(prefs.getBoolean(ID1, true));
prefs.putBoolean(ID1, false);
//prefs.remove(ID1);
Is this variable…

stackoverflow
- 18,348
- 50
- 129
- 196
12
votes
6 answers
How do I create one Preference with an EditTextPreference and a Togglebutton?
What I'm trying to implement is basically and exact replica of the image below (the preferences that I've squared). Pressing anything to the left of the preference should open up a dialog. Pressing the togglebutton will disable/enable whatever I'm…

CodePrimate
- 6,646
- 13
- 48
- 86
12
votes
2 answers
How to disable Thunderbird AUTO UPDATE
How can i disable the AUTO UPDATE process/function automatically used/applied by the (Mozilla) Thunderbird=TB (email-client) app ? for-example in v68 series: v68.12.0 or v68.12.1, etc ?
What settings/preferences change are needed ?
please show…

atErik
- 923
- 2
- 13
- 24
12
votes
2 answers
Make Preference look disabled, but still register clicks
So during certain states in my app, I want to disable certain CheckBoxPreferences in my setting-menu. However, if the user clicks them, I want an explanatory toast to be shown. If i just do setEnable(false); on the CheckBoxPreference, I do get the…

pgsandstrom
- 14,361
- 13
- 70
- 104
12
votes
2 answers
Programmatically enabling/disabling screen rotations in Android
I have an app which displays a large amount of text for the user to read.
I've found that when reading while lying down, I get annoyed that the screen rotates even though my head and the screen are aligned.
I do not want to set this to be…

jamesh
- 19,863
- 14
- 56
- 96
12
votes
3 answers
How do you validate the format and values of EditTextPreference entered in Android 2.1?
Does anyone have sample code to validate user entered text in preferences? For example, I have a EditTextPreference for user to enter an email address. I'd like to validate the format of email address entered and pop up an alert dialog if the format…

Bryan C
- 1,594
- 4
- 16
- 30
12
votes
3 answers
Shared Preferences not persistent after app restart
I found all answers here and tried all solutions, still my shared prefs are not persistent.
Here's my code:
public static void setActivated(boolean activated) {
SharedPreferences sp = Utils.getContext().getSharedPreferences(
…

Razvan
- 493
- 5
- 16
12
votes
3 answers
Show up-Button in actionBar in subscreen preferences
I've implemented my preferences like shown in the official guidelines.
I have a PreferenceActivity which creates the PreferenceFragment like this:
@Override
protected void onCreate(Bundle savedInstanceState)
{
…

user1567896
- 2,398
- 2
- 26
- 43
12
votes
2 answers
Android exploit dalvik classes: Preferences
Recently, i have been trying to understand how some apps manage to change android browser settings by code like the homepage. This is how "far" i have come. It is not support by the android api and normal code. You have to use native code. I…

Ukjent
- 823
- 2
- 9
- 26