You can use this code to implement a singleton class for configuration 
using writable SharedPreferences.

public final class Config {

private static Config INSTANCE = new Config();
private ConfigProperties configProperties;

private Config(){}

public static Config getInstance() {
return INSTANCE;
}

public void init(Context context) {
configProperties = new ConfigProperties(context);
}

}

public class ConfigProperties {

private SharedPreferences preferences;
private SharedPreferences.Editor editor;

public ConfigProperties(Context parent) { 

preferences = PreferenceManager
.getDefaultSharedPreferences(parent.getApplicationContext());

editor = preferences.edit();

}

public String getStringProperty(String key) {
return preferences.getString(key, null);
}

public Integer getIntegerProperty(String key) {
return preferences.getInt(key, 0);
}

public Boolean getBooleanProperty(String key) {
return preferences.getBoolean(key, false);
}

public void setStringProperty(String key, String value) {
editor.putString(key, value);
editor.commit();
}

public void setIntegerProperty(String key, int value) {
editor.putInt(key, value);
editor.commit();
} 

public void setBooleanProperty(String key, boolean value) {
editor.putBoolean(key, value);
editor.commit();
}

}

El miércoles, 8 de agosto de 2012 08:04:39 UTC+2, Sadhna Upadhyay escribió:
>
>   Hi Everyone,
> can any one tell me  how to pass Numeric value from one activity to 
> another activity and how to get  numeric value from another activity 
> through shered preference.
>
>
> thanks
>  sadhana
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to