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 -

ios - Subclassing UIView and adding a property -

Powerbuilder 12.1 and DataWindow in Design vs Debug and Executable/Runtime -