preferencemanager is deprecated

Deprecated PreferenceManager in Kotlin

// Step 1: Use Context.getSharedPreferences() to obtain SharedPreferences instance
val sharedPreferences = context.getSharedPreferences("my_preferences", Context.MODE_PRIVATE)

// Step 2: Use SharedPreferences.Editor to modify the preferences
val editor = sharedPreferences.edit()

// Step 3: Use editor.apply() to save changes
editor.putString("key", "value")
editor.apply()

// Step 4: Use editor.remove() to remove a preference
editor.remove("key")
editor.apply()

// Step 5: Use editor.clear() to clear all preferences
editor.clear()
editor.apply()

// Step 6: Use SharedPreferences methods to retrieve data
val value = sharedPreferences.getString("key", "default_value")