There is only one thing to pay attention to, that is, the key name or item name should not contain capital letters, otherwise the data cannot be read.
The code is like this:
Copy the code code as follows:
Preferences preferences = Preferences.systemRoot();
String strRegTime = preferences.get("regTime", "");
This is what is in the registry
No matter how I change it, I can't read the value of regTime. Later I thought of writing the value in the code now to see what it looks like. The code is as follows
Copy the code code as follows:
Preferences preferences = Preferences.systemRoot();
preferences.put("regTime", "2013-08-29 14:50:20");
try {
preferences.flush();
} catch (BackingStoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String strRegTime = preferences.get("regTime", "");
It turns out this is the case
So I found the problem and changed it to lowercase and it was ok.