I want to save a string value in android activity using SharedPreferences.
This is my SearchUserAdapter class : here only passing the search people user id :
final String searchuserid = Order.get(SearchProfile.TAG_USER_ID);
username_search.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent in = new Intent(activity,
SearchProfile.class);
in.putExtra("UserId", searchuserid);
activity.startActivity(in);
}
});
return vi;
}
In this SearchProfile.class:
Intent i = getIntent();
userid = i.getStringExtra("UserId");
SharedPreferences loginPreferences = getSharedPreferences(M_SPF_NAME,
Context.MODE_PRIVATE);
loginPreferences.edit().putString(M_USERNAME, userid).commit();
Here if I have reloaded the SearchPorile activity many times means that time also need to get the same user id when selecting the another user id from that SearchUserAdapter class. How can I save this value ? Any suggestion or idea will be appreciated.
Preferencesin ActivityonPause()and load it on ActivityonResume()