{"id":13536760,"url":"https://github.com/florent37/Multiplatform-Preferences","last_synced_at":"2025-04-02T03:31:03.843Z","repository":{"id":91120180,"uuid":"156118714","full_name":"florent37/Multiplatform-Preferences","owner":"florent37","description":"Kotlin Multi Platform Preferences, for android an ios : SharedPreferences \u0026 NSUserDefault","archived":true,"fork":false,"pushed_at":"2020-02-18T12:50:58.000Z","size":25065,"stargazers_count":86,"open_issues_count":4,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-03T01:33:21.901Z","etag":null,"topics":["android","default","ios","java","kotlin","multiplatform","native","nsuserdefaults","preferences","session","sharedpreferences"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/florent37.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-11-04T19:49:12.000Z","updated_at":"2024-04-30T01:16:08.000Z","dependencies_parsed_at":"2024-01-16T15:40:23.547Z","dependency_job_id":"43ba25d4-1699-4d45-9e50-a4dd96013f7f","html_url":"https://github.com/florent37/Multiplatform-Preferences","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FMultiplatform-Preferences","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FMultiplatform-Preferences/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FMultiplatform-Preferences/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FMultiplatform-Preferences/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/florent37","download_url":"https://codeload.github.com/florent37/Multiplatform-Preferences/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246751006,"owners_count":20827817,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","default","ios","java","kotlin","multiplatform","native","nsuserdefaults","preferences","session","sharedpreferences"],"created_at":"2024-08-01T09:00:49.031Z","updated_at":"2025-04-02T03:31:03.106Z","avatar_url":"https://github.com/florent37.png","language":"Kotlin","readme":"# Multiplatform Preferences\n\nUse a single object : `Preferences` in your kotlin shared projects\n\nCompatible with kotlin android and kotlin native for iphone\n\n```kotlin\nclass MyPresenter {\n    val preferences = Preferences()\n\n    fun start(){\n        preferences.getString(\"userName\")?.let {\n            view.displayUser(it)\n        }\n        \n        val age = preferences.getInt(\"age\", 18)\n        view.displayUserAge(age)\n    }\n}\n```\n\n\n# Download\n\nAdd the repository\n```groovy\nrepositories {\n    maven { url \"https://dl.bintray.com/florent37/maven\" }\n}\n```\n\n## common\n```groovy\nimplementation \"com.github.florent37:multiplatform-preferences:1.2.0\"\n```\n\n## ios\n\nUses inside the NSUserDefaults\n\n```groovy\nimplementation \"com.github.florent37:multiplatform-preferences-ios:1.2.0\"\n```\n\n## android\n\nUses inside the SharedPreferences\n\n```groovy\nimplementation \"com.github.florent37:multiplatform-preferences-android:1.2.0\"\n```\n\n## Methods\n\n```kotlin\nclass Preferences(name: String? = null) {\n\n    fun setInt(key: String, value: Int)\n    fun getInt(key: String, defaultValue: Int): Int\n    fun getInt(key: String): Int?\n\n    fun setFloat(key: String, value: Float)\n    fun getFloat(key: String, defaultValue: Float): Float\n    fun getFloat(key: String): Float?\n\n    fun setLong(key: String, value: Long)\n    fun getLong(key: String, defaultValue: Long): Long\n    fun getLong(key: String): Long?\n\n    fun setString(key: String, value: String)\n    fun getString(key: String, defaultValue: String): String\n    fun getString(key: String): String?\n\n    fun setBoolean(key: String, value: Boolean)\n    fun getBoolean(key: String, defaultValue: Boolean): Boolean\n    fun getBoolean(key: String): Boolean?\n\n    fun remove(key: String)\n    fun clear()\n\n    fun hasKey(key: String): Boolean\n}\n```\n \n## License\n        \n    Copyright 2018 Florent37\n    \n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n    \n       http://www.apache.org/licenses/LICENSE-2.0\n    \n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.","funding_links":[],"categories":["Libraries"],"sub_categories":["Storage"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorent37%2FMultiplatform-Preferences","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflorent37%2FMultiplatform-Preferences","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorent37%2FMultiplatform-Preferences/lists"}