When I perform:
sharedPref.putString("id", null)
it comes up in my sharedPrefs
file like this:
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<boolean name="waiting" value="false" />
<string name="state">initial</string>
<string name="id"></string>
</map>
And when I try to retrieve it:
val id = sharedPref.getString("id", null) ?: return // doesn't return
Log.d(TAG, "id == blank: ${id.isBlank()}") // true
it says the value is blank and not null.
So if a string in sharedPrefs has been set to null, it will not actually be null? It will be blank (""
).
I would like to make it null so it is easier to check with Kotlin's null safety - however I'm not sure if this is possible?