java - Writing Background color -
I am trying to write a background color with three sebbars. I use this code:
shared context mColor; Public static final string APP_PREFERENCES_COLOR = "color"; Color S = RGBTOX (R, G, B); Try {Editor Editor = mColor.edit (); Editor.putString (APP_PREFERENCES_COLOR, COLOR S); Editor.apply (); } Hold (exception e) {toast. GetApplicationContext, e. Toasting (), toast. LNNGHHORT). Show (); }}
But I can see the message "java.lang.NullPointerExeption" How can I fix this?
When you receive the editor, the shared options are zero. Try:
mColor = PreferenceManager.getDefaultSharedPreferences (getApplicationContext ()); Editor Editor = mColor.edit (); Editor.putString (APP_PREFERENCES_COLOR, COLOR S); Editor.commit ();
should correct your problem
Hope it helps.
Comments
Post a Comment