aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefFactory.kt
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefFactory.kt')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefFactory.kt22
1 files changed, 22 insertions, 0 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefFactory.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefFactory.kt
new file mode 100644
index 0000000..0c49b88
--- /dev/null
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefFactory.kt
@@ -0,0 +1,22 @@
+package ca.allanwang.kau.kpref
+
+import android.content.Context
+
+interface KPrefFactory {
+ fun createBuilder(preferenceName: String): KPrefBuilder
+}
+
+/**
+ * Default factory for Android preferences
+ */
+class KPrefFactoryAndroid(context: Context) : KPrefFactory {
+
+ val context: Context = context.applicationContext
+
+ override fun createBuilder(preferenceName: String): KPrefBuilder =
+ KPrefBuilderAndroid(context.getSharedPreferences(preferenceName, Context.MODE_PRIVATE))
+}
+
+object KPrefFactoryInMemory : KPrefFactory {
+ override fun createBuilder(preferenceName: String): KPrefBuilder = KPrefBuilderInMemory
+} \ No newline at end of file