Skip to content Skip to sidebar Skip to footer

Does SharedPreferences Use A Certain Character Set?

I have just noticed that SharedPreferences removes carriage return (\r) when storing a string. Since it was quite costly for me to not know this, I would like to know if it remove

Solution 1:

Good morning,

It is even worst: if you store the String "\r" into SharedPref, after killing and restarting application, the value from SharedPref will become "\n".

Another bug from our beloved Android platform, very annoying...

Cheers


Solution 2:

In other words, does it use a certain character set.

When you write your SharedPreferences to the disk, it uses XmlUtils.writeMapXml, which outputs in UTF-8.


Post a Comment for "Does SharedPreferences Use A Certain Character Set?"