In two different activity, a in sharedpreferences saved the data, in a can be read, but in B but not read, has been empty value, good is uncomfortable, because it is according to the example of the book, How can not find the reason, It was later discovered that a name was needed when it was saved before it could be read in another activity.
The example in the book is like this.
Sharedpreferences.editor ed= getpreferences (mode_private). Edit ();
The following code is then read to the
Sharedpreferences sp=getpreferences (mode_private); U=sp.getstring ("user", "T");
There is no problem reading in the same activity, but when read in another activity, the value is not read.
It was later discovered that it was necessary to give it a name when it was saved and then read it by name.
Sharedpreferences sp=getsharedpreferences ("PPPoE", mode_private);
At the time of reading
Sharedpreferences sp=getsharedpreferences ("PPPoE", mode_private); uid= sp.getstring ("User", "1235");
So there is no problem, it seems that the author of the book is not too hard.
Problems with sharedpreferences not reading data in Android