In my Application ,upon login I am saving the user details like (userName, Id ,email etc.) in a sharedPreference file, so that I can access those anywhere in my application, I am doing it like this
public void put(String fileName, String key, String value)
{
SharedPreferences sharedPref = getContext().getSharedPreferences(fileName, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString(key, value);
editor.commit();
}
now I have spawned a different thread, which will run independently (something like Sync), I am accessing sharedPreference like this ,
mContext.getSharedPreferences(fileName, Context.MODE_PRIVATE);
but all the values in this particular preference are returned as null, am I doing anything wrong,
PS :- If I kill the app and again same thread gets spawned, I can acess the values (its quite strange, but this is happening, i.e. when user logs in for first time , these details are not accessible)
feels like sync issue with SharedPreferences , can anyone help on this?