I'm attempting to write new value into a Shared Preference and seems not to work, am I missing something.
// this tests output
System.out.println("This OLD ID : "+oldPost+ " - NEW ID :"+postID);
// output : This OLD ID : 5233 - NEW ID :5216
///get old id
SharedPreferences prefs = getSharedPreferences("MyPrefs", MODE_PRIVATE);
String oldPost = prefs.getString("newsId", null);
if (oldPost.equals(postID))
{
System.out.println("This has been alerted : ");
}
else
{
System.out.println("This is something new : ");
//set old post to new post - does not seem to work
SharedPreferences.Editor editor = getSharedPreferences("MyPrefs", MODE_PRIVATE).edit();
editor.clear();
editor.putString("newsId", "" + oldPost);
editor.commit();
}
}
Hope this is a obvious answer... Thanks in advance.