I backup the SharedPreferences xml file to the SD card, from the file
File taskExceptionFile = new File(Environment.getDataDirectory()
+ "/data/" + packageName + "/shared_prefs/" + TaskAction.SHARED_PREF_TITLE_TASK_EXCEPTION + ".xml");
however, when I restore the file, if the file has been open by
SharedPreferences sp = context.getSharedPreferences(TaskAction.SHARED_PREF_TITLE_TASK_EXCEPTION, 0);
before restoring, the SharedPreferences seems to have a cache, I use Root Explorer to see the file after restoring, the values are indeed the values from the backup file, but when I use
sp.getInt(TaskAction.SHARED_PREF_TASK, 0)
to get the value, the value is not the new value from the backup file, it returns the default value 0. I force stop my app, and reenter my app, the values are the new values.
So, I want to ask how to refresh the SharedPreferences immediately when I restore the file, so that I can get the new value?
Sorry for my poor English~~~