{"id":13735292,"url":"https://github.com/Bilibili/xpref","last_synced_at":"2025-05-08T11:32:55.855Z","repository":{"id":67623490,"uuid":"115354349","full_name":"bilibili/xpref","owner":"bilibili","description":"A SharedPreferences' wrapper that truly supported sharing data across multi-process","archived":false,"fork":false,"pushed_at":"2017-12-27T15:40:22.000Z","size":163,"stargazers_count":84,"open_issues_count":0,"forks_count":12,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-11T12:19:39.985Z","etag":null,"topics":["android-library","sharedpreferences"],"latest_commit_sha":null,"homepage":"","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/bilibili.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-25T17:43:41.000Z","updated_at":"2024-06-03T17:53:28.000Z","dependencies_parsed_at":"2023-05-25T06:00:41.268Z","dependency_job_id":null,"html_url":"https://github.com/bilibili/xpref","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bilibili%2Fxpref","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bilibili%2Fxpref/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bilibili%2Fxpref/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bilibili%2Fxpref/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bilibili","download_url":"https://codeload.github.com/bilibili/xpref/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224727178,"owners_count":17359532,"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-library","sharedpreferences"],"created_at":"2024-08-03T03:01:05.135Z","updated_at":"2024-11-15T03:31:42.380Z","avatar_url":"https://github.com/bilibili.png","language":"Kotlin","funding_links":[],"categories":["Libraries"],"sub_categories":["Android"],"readme":"Xpref\n====\n\nA SharedPreferences' wrapper that truly supported sharing data across multi-process\n\n### Principle\n\nContentProvider is designed to provide content between multiple applications that means it supported\nsharing data between multi-process. Use it to wrap the SharedPreferences can make the latter truly\ncross-process sharing data\n\n### Usage\n\nAdd dependency to your gradle script:\n\n```groovy\ndependencies {\n    implementation 'com.bilibili.lib:x-pref:1.2'\n}\n```\n\nNote that this library is written with kotlin 1.2.10.\n\n1. Gets the default SharedPreferences which is typically used in the Settings of an APP.\n\n```kotlin\nXpref.getDefaultSharedPreferences(context)\n```\n\n2. Gets a SharedPreferences with specific named.\n\n```kotlin\nval name = \"awesome\"\nXpref.getSharedPreferences(context, name)\n```\n\n3. Extension in Kotlin.\n\nYou can declare extension functions in somewhere on your need for better convenience usage like following:\n\n```kotlin\nfun \u003cT: ContextWrapper\u003e T.xpref() = Xpref.getDefaultSharedPreferences(this)\n\nfun \u003cT: ContextWrapper\u003e T.xpref(name: String) = Xpref.getSharedPreferences(this, name)\n```\n```kotlin\n// in Activity\nclass AnActivity : Activity() {\n    private fun getPreferences() = this.xpref(\"awesome\")\n}\n\n// in Service\nclass AService : Service() {\n    private fun getPreferences() = this.xpref(\"awesome\")\n}\n```\n\nThe other usage is the same as normal SharedPreferences.\n\nHave fun!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBilibili%2Fxpref","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBilibili%2Fxpref","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBilibili%2Fxpref/lists"}