I tried to update the sharePreference value using json object. First I create the json object with name, then update the object in sharedPreference. But, I unable to get the json object name. Please help me.
team1.put("name", "India")
updateData(team1)
private fun updateData(data: JSONObject) {
val sharedPref: SharedPreferences = getSharedPreferences("SharedPref1", 0)
val editor:SharedPreferences.Editor = sharedPref.edit()
editor.putString("JSONObjectName",data.toString()) // How to get the JSONObject name?
}
I want to like this, data.name == team1.