android - how to use Shared Prefrences -


i want know how use shared prefrences .... problem using shared prefrence ...i m not filling in edit text if condition not working ...when pressed without filling in edit text ..curser going next activity if condition not working debugger showing no value not null..if filling information degugger showing me value have entered

here code

public class signupe extends activity { sharedpreferences pref; context context; editor editor; button nexttofinish; edittext fulname,username,datofbirth,email,password; @override protected void oncreate(bundle savedinstancestate) {     // todo auto-generated method stub     super.oncreate(savedinstancestate);     setcontentview(r.layout.signupe);     pref=getapplicationcontext().getsharedpreferences("mydata",             context.mode_private);       nexttofinish=(button)findviewbyid(r.id.nexttofinish);      fulname=(edittext)findviewbyid(r.id.fulname);      username=(edittext)findviewbyid(r.id.user_name);      datofbirth=(edittext)findviewbyid(r.id.dateofbrth);      email=(edittext)findviewbyid(r.id.email_user);      password=(edittext)findviewbyid(r.id.pwd_user);     nexttofinish=(button)findviewbyid(r.id.nexttofinish);         nexttofinish.setonclicklistener(new view.onclicklistener() {          @override         public void onclick(view v) {              // todo auto-generated method stub             string fullname=fulname.gettext().tostring();             string username=username.gettext().tostring();             string dateofbirth=datofbirth.gettext().tostring();             string e_mail=email.gettext().tostring();             string password=password.gettext().tostring();             if(fulname.equals(""))             {                 toast.maketext(signupe.this,"please full name", toast.length_short).show();                 return;             }             if(username.equals(""))             {                 toast.maketext(signupe.this,"please enter user name display", toast.length_short).show();                 return;             }if(datofbirth.equals(""))             {                 toast.maketext(signupe.this,"please enter date of birth", toast.length_short).show();                 return;             }              if(email.equals(""))             {                 toast.maketext(signupe.this,"please enter email", toast.length_short).show();                 return;             }               if(password.equals(""))             {                                toast.maketext(signupe.this,"please enter strong password", toast.length_short).show();                 return;             }              editor=pref.edit();             editor.putstring("fullname", fullname);             editor.putstring("username", username);             editor.putstring("datofbirth", dateofbirth);             editor.putstring("email", e_mail);             editor.putstring("password", password);             editor.commit();             intent f=new intent(getapplicationcontext(),signup.class);             startactivity(f);           }     }); }    } 

use this

 if(fullname.matches(""))             {                 toast.maketext(signupe.this,"please full name", toast.length_short).show();                 return;             } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -