-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement presentNextTime for Android (#16)
- Loading branch information
Showing
4 changed files
with
79 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.neoversion | ||
|
||
import android.content.Context | ||
import android.content.SharedPreferences | ||
|
||
class NeoPreference(private val context: Context) { | ||
private val sharedPreferences: SharedPreferences = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE) | ||
fun save(key: String, value: String) { | ||
val editor = sharedPreferences.edit() | ||
editor.putString(key, value) | ||
editor.apply() | ||
} | ||
fun save(key: String, value: Int) { | ||
val editor = sharedPreferences.edit() | ||
editor.putInt(key, value) | ||
editor.apply() | ||
} | ||
fun save(key : String, status: Boolean){ | ||
val editor = sharedPreferences.edit() | ||
editor.putBoolean(key, status) | ||
editor.apply() | ||
} | ||
|
||
fun getValueString(key: String): String? { | ||
return sharedPreferences.getString(key, null) | ||
} | ||
|
||
fun getValueInt(key: String): Int { | ||
return sharedPreferences.getInt(key, 0) | ||
} | ||
|
||
fun getValueBoolean(key: String, defaultValue: Boolean) : Boolean{ | ||
return sharedPreferences.getBoolean(key, defaultValue) | ||
} | ||
|
||
fun clearSharedPreferences(){ | ||
val editor = sharedPreferences.edit() | ||
editor.clear() | ||
editor.apply() | ||
} | ||
|
||
fun removeValue(key: String){ | ||
val editor = sharedPreferences.edit() | ||
editor.remove(key) | ||
editor.apply() | ||
} | ||
|
||
companion object { | ||
const val PREF_NAME = "neo-version-preference" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters