I am new to android!. I have made spinner in activity 1 (one time open Activity) and want to transfer selected value from spinner by user to activity 2.I have used sharedPreference for one time open activity .Its only working 1st time but second time it cant transfer data.I am stuck here please help me
SharedPreferences Preferences=getSharedPreferences("PREFERENCE",MODE_PRIVATE);
String FirstTime=Preferences.getString("FirstTimeInstall","");
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String parent=sp_parent.getSelectedItem().toString();
String child=sp_child.getSelectedItem().toString();
String college=sp_college.getSelectedItem().toString();
Intent intent=new Intent(getApplicationContext(),Dashboard.class);
intent.putExtra("parent",parent);
intent.putExtra("child",child);
intent.putExtra("college",college);
startActivity(intent);
finish();
}
});
if (FirstTime.equals("Yes")){
String parent=sp_parent.getSelectedItem().toString();
String child=sp_child.getSelectedItem().toString();
String college=sp_college.getSelectedItem().toString();
Intent intent=new Intent(getApplicationContext(),Dashboard.class);
intent.putExtra("parent",parent);
intent.putExtra("child",child);
intent.putExtra("college",college);
startActivity(intent);
finish();
}else {
SharedPreferences.Editor editor=Preferences.edit();
editor.putString("FirstTimeInstall","Yes");
editor.apply();
}