Your first problem is that (UserName != null)
is always true.
You are getting UserName
with String UserName = settings.getString("UserName", "");
, which will provide a default value of an empty String. If you want the settings to return null if the preference is not found, you should call settings.getString("UserName", null)
.
Your second problem is that you never call setOnClickListener(this)
on any of the Views in your InitialPreferences
Activity. Thus onClick()
is never called, and nothing happens. I'm assuming you want to call button1.setOnClickListener(this)
in onCreate()
.