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

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -