Kullanıcı adı ve parola boş veya boş değilse, SharedPreferences'da bir dizgiyi kullanıcı adı ve parola saklamak için kullandığımı kontrol etmek istiyorum. kullanıcı adı ve şifre boş olduğundan giriş sayfasına yönlendirilecektir.SharedPreferences dizgisi nasıl kontrol edilir boş veya boş * android
Bu SharedPreferences dize kontrol etmek benim kod, ancak çalışmıyor ..
if(PreferenceConnector.USERNAME!=null){
Intent intent = new Intent(MainActivity.this,MainHome_Activity.class);
startActivity(intent);
} else {
Intent intent = new Intent(MainActivity.this,LoginFormPegawai_Activity.class);
startActivity(intent);
}
Bu kod ile tost aracılığıyla kontrol etmeye çalıştı ve bu çalıştı sonra ben SharedPreferences olsun dize onun boş veya boş olup olmadığını
btn_logout_pegawai.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//remove the SharedPreferences string
PreferenceConnector.getEditor(this).remove(PreferenceConnector.USERNAME)
.commit();
PreferenceConnector.getEditor(this).remove(PreferenceConnector.PASSWORD)
.commit();
//checking the SharedPreferences string
if(PreferenceConnector.USERNAME!=null){
Toast.makeText(MainHome_Activity.this,"not null", Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(MainHome_Activity.this,"null", Toast.LENGTH_SHORT).show();
}
}
});
nasıl doğru SharedPreferences dize kontrol edebilirsiniz .. null veya boş değil?
Teşekkür ..
sayesinde , onun çalışma .. –
yardım etmekten memnun. İyi şanslar! –
@AnupCowkur bunu kontrol edebilir misiniz? Http://stackoverflow.com/questions/36959279/how-do-i-use-a-dialogue-in-my-android-app-just-before-the-start-of- hizmet – Abhishek