{"id":855,"date":"2023-10-02T07:49:48","date_gmt":"2022-09-30T21:36:06","guid":{"rendered":"https:\/\/www.silicloud.com\/ja\/blog\/index.php\/2023\/11\/30\/kotlin%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9fandroid%e3%81%aesharedpreferences\/"},"modified":"2025-08-01T03:02:57","modified_gmt":"2025-07-31T18:02:57","slug":"kotlin%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9fandroid%e3%81%aesharedpreferences","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/ja\/blog\/kotlin%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9fandroid%e3%81%aesharedpreferences\/","title":{"rendered":"Kotlin\u3092\u4f7f\u7528\u3057\u305fAndroid\u306eSharedPreferences"},"content":{"rendered":"<p>\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001Kotlin\u3092\u4f7f\u7528\u3057\u3066Android\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067SharedPreferences\u3092\u5b9f\u88c5\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u5b66\u3073\u307e\u3059\u3002<\/p>\n<h2>Android\u306eSharedPreferences\u3068\u306f\u4f55\u3067\u3059\u304b\uff1f<\/h2>\n<p>SharedPreferences\u306f\u3001API\u30ec\u30d9\u30eb1\u304b\u3089Android API\u306e\u4e00\u90e8\u3067\u3059\u3002\u3053\u308c\u306f\u3001\u30c7\u30fc\u30bf\u3092\u30ed\u30fc\u30ab\u30eb\u306b\u4fdd\u5b58\/\u5909\u66f4\/\u524a\u9664\u3059\u308b\u305f\u3081\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3067\u3059\u3002\u4e00\u822c\u7684\u306b\u3001\u30ed\u30b0\u30a4\u30f3\u30d5\u30a9\u30fc\u30e0\u306a\u3069\u306e\u30e6\u30fc\u30b6\u30fc\u306e\u30ed\u30fc\u30ab\u30eb\u30c7\u30fc\u30bf\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u30c7\u30fc\u30bf\u306f\u30ad\u30fc\u3068\u5024\u306e\u30da\u30a2\u306e\u5f62\u5f0f\u3067\u4fdd\u5b58\u3055\u308c\u307e\u3059\u3002SharedPreferences\u30c7\u30fc\u30bf\u3092\u4fdd\u6301\u3059\u308b\u305f\u3081\u306b\u8907\u6570\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>SharedPreferences\u306e\u30e1\u30bd\u30c3\u30c9<\/h2>\n<p>SharedPreferences\u306b\u3064\u3044\u3066\u306e\u91cd\u8981\u306a\u30e1\u30bd\u30c3\u30c9\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<ul class=\"post-ul\">\n<li>getSharedPreferences(String, int) method is used to retrieve an instance of the SharedPreferences. Here String is the name of the SharedPreferences file and int is the Context passed.<\/li>\n<li>The SharedPreferences.Editor() is used to edit values in the SharedPreferences.<\/li>\n<li>We can call commit() or apply() to save the values in the SharedPreferences file. The commit() saves the values immediately whereas apply() saves the values asynchronously.<\/li>\n<\/ul>\n<h2>Kotlin\u3092\u4f7f\u3063\u3066SharedPreferences\u306e\u5024\u3092\u8a2d\u5b9a\u30fb\u53d6\u5f97\u3059\u308b\u65b9\u6cd5<\/h2>\n<p>\u79c1\u305f\u3061\u306f\u3001Kotlin\u3092\u4f7f\u7528\u3057\u3066SharedPreference\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u5024\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>val sharedPreference =  getSharedPreferences(\"PREFERENCE_NAME\",Context.MODE_PRIVATE)\r\nvar editor = sharedPreference.edit()\r\neditor.putString(\"username\",\"Anupam\")\r\neditor.putLong(\"l\",100L)\r\neditor.commit()\r\n<\/code><\/pre>\n<p>\u5024\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306b\uff1a<\/p>\n<pre class=\"post-pre\"><code>sharedPreference.getString(\"username\",\"defaultName\")\r\nsharedPreference.getLong(\"l\",1L)\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649f20daa94e2bdf7c2374\/11-0.png\" alt=\"android shared preference types\" \/><\/div>\n<h2>SharedPreferences\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u30af\u30ea\u30a2\u304a\u3088\u3073\u524a\u9664\u3059\u308b\u305f\u3081\u306eKotlin\u30b3\u30fc\u30c9<\/h2>\n<p>\u79c1\u305f\u3061\u306f\u3001clear() \u30e1\u30bd\u30c3\u30c9\u3068 remove(String key) \u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u3067\u3001\u5168\u3066\u306e\u5024\u3092\u30af\u30ea\u30a2\u3057\u305f\u308a\u7279\u5b9a\u306e\u5024\u3092\u524a\u9664\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>editor.clear()\r\neditor.remove(\"username\")\r\n<\/code><\/pre>\n<p>\u6ce8\u610f\uff1a\u30b3\u30df\u30c3\u30c8\u307e\u305f\u306f\u9069\u7528\u5f8c\u306e\u30a8\u30c7\u30a3\u30bf\u30fc\u3078\u306e\u5909\u66f4\u306f\u8003\u616e\u3055\u308c\u307e\u305b\u3093\u3002SharedPreference\u304b\u3089\u5024\u3092\u4fdd\u5b58\u304a\u3088\u3073\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u306f\u3001Java\u3067\u884c\u3046\u65b9\u6cd5\u3068\u307b\u307c\u540c\u3058\u3067\u3059\u3002\u3067\u306f\u3001Kotlin\u306e\u9b54\u6cd5\u306f\u3069\u3053\u306b\u3042\u308b\u306e\u3067\u3057\u3087\u3046\u304b\uff1f\u6b21\u306b\u3001Android\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u4f8b\u3092\u901a\u3058\u3066\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>\u30a2\u30f3\u30c9\u30ed\u30a4\u30c9\u306eSharedPreferences Kotlin\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u69cb\u9020<\/h2>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649f20daa94e2bdf7c2374\/17-0.png\" alt=\"android shared preference kotlin project\" \/><\/div>\n<h3>1. \u30b3\u30fc\u30c9\u306e\u914d\u7f6e<\/h3>\n<p>\u4ee5\u4e0b\u306b activity_main.xml \u30ec\u30a4\u30a2\u30a6\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u30b3\u30fc\u30c9\u304c\u793a\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;RelativeLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    android:orientation=\"vertical\"&gt;\r\n\r\n    &lt;EditText\r\n        android:id=\"@+id\/inUserId\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_alignParentTop=\"true\"\r\n        android:hint=\"User ID\"\r\n        android:inputType=\"number\" \/&gt;\r\n\r\n    &lt;EditText\r\n        android:id=\"@+id\/inPassword\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_below=\"@+id\/inUserId\"\r\n        android:hint=\"Password\"\r\n        android:inputType=\"textPassword\" \/&gt;\r\n\r\n    &lt;Button\r\n        android:id=\"@+id\/btnSave\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_below=\"@+id\/inPassword\"\r\n        android:text=\"SAVE USER DATA\" \/&gt;\r\n\r\n    &lt;Button\r\n        android:id=\"@+id\/btnClear\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_alignParentLeft=\"true\"\r\n        android:layout_alignParentStart=\"true\"\r\n        android:layout_below=\"@+id\/btnSave\"\r\n        android:text=\"CLEAR USER DATA\" \/&gt;\r\n\r\n    &lt;Button\r\n        android:id=\"@+id\/btnShow\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_alignParentRight=\"true\"\r\n        android:layout_below=\"@+id\/inPassword\"\r\n        android:text=\"SHOW\" \/&gt;\r\n\r\n    &lt;Button\r\n        android:id=\"@+id\/btnShowDefault\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_alignParentEnd=\"true\"\r\n        android:layout_alignParentRight=\"true\"\r\n        android:layout_below=\"@+id\/btnSave\"\r\n        android:text=\"Show Default\" \/&gt;\r\n\r\n\r\n&lt;\/RelativeLayout&gt;\r\n<\/code><\/pre>\n<h3>2. MainActivity\u306eKotlin\u30b3\u30fc\u30c9\u3002<\/h3>\n<p>\u4e0b\u8a18\u306bMainActivity.kt\u306eKotlin\u30af\u30e9\u30b9\u306e\u30b3\u30fc\u30c9\u304c\u8a18\u8f09\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.androidlysharedpreferences\r\n\r\nimport android.content.Context\r\nimport android.content.SharedPreferences\r\nimport android.support.v7.app.AppCompatActivity\r\nimport android.os.Bundle\r\nimport android.preference.PreferenceManager\r\nimport android.view.View\r\nimport com.scdev.androidlysharedpreferences.PreferenceHelper.defaultPreference\r\nimport com.scdev.androidlysharedpreferences.PreferenceHelper.password\r\nimport com.scdev.androidlysharedpreferences.PreferenceHelper.userId\r\nimport com.scdev.androidlysharedpreferences.PreferenceHelper.clearValues\r\nimport com.scdev.androidlysharedpreferences.PreferenceHelper.customPreference\r\n\r\nimport kotlinx.android.synthetic.main.activity_main.*\r\n\r\nclass MainActivity : AppCompatActivity(), View.OnClickListener {\r\n\r\n    val CUSTOM_PREF_NAME = \"User_data\"\r\n\r\n    override fun onCreate(savedInstanceState: Bundle?) {\r\n        super.onCreate(savedInstanceState)\r\n        setContentView(R.layout.activity_main)\r\n\r\n        btnSave.setOnClickListener(this)\r\n        btnClear.setOnClickListener(this)\r\n        btnShow.setOnClickListener(this)\r\n        btnShowDefault.setOnClickListener(this)\r\n\r\n    }\r\n\r\n    override fun onClick(v: View?) {\r\n        val prefs = customPreference(this, CUSTOM_PREF_NAME)\r\n        when (v?.id) {\r\n            R.id.btnSave -&gt; {\r\n                prefs.password = inPassword.text.toString()\r\n                prefs.userId = inUserId.text.toString().toInt()\r\n            }\r\n            R.id.btnClear -&gt; {\r\n                prefs.clearValues\r\n\r\n            }\r\n            R.id.btnShow -&gt; {\r\n                inUserId.setText(prefs.userId.toString())\r\n                inPassword.setText(prefs.password)\r\n            }\r\n            R.id.btnShowDefault -&gt; {\r\n\r\n                val defaultPrefs = defaultPreference(this)\r\n                inUserId.setText(defaultPrefs.userId.toString())\r\n                inPassword.setText(defaultPrefs.password)\r\n            }\r\n        }\r\n    }\r\n\r\n\r\n}\r\n\r\nobject PreferenceHelper {\r\n\r\n    val USER_ID = \"USER_ID\"\r\n    val USER_PASSWORD = \"PASSWORD\"\r\n\r\n    fun defaultPreference(context: Context): SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)\r\n\r\n    fun customPreference(context: Context, name: String): SharedPreferences = context.getSharedPreferences(name, Context.MODE_PRIVATE)\r\n\r\n    inline fun SharedPreferences.editMe(operation: (SharedPreferences.Editor) -&gt; Unit) {\r\n        val editMe = edit()\r\n        operation(editMe)\r\n        editMe.apply()\r\n    }\r\n\r\n    var SharedPreferences.userId\r\n        get() = getInt(USER_ID, 0)\r\n        set(value) {\r\n            editMe {\r\n                it.putInt(USER_ID, value)\r\n            }\r\n        }\r\n\r\n    var SharedPreferences.password\r\n        get() = getString(USER_PASSWORD, \"\")\r\n        set(value) {\r\n            editMe {\r\n                it.putString(USER_PASSWORD, value)\r\n            }\r\n        }\r\n\r\n    var SharedPreferences.clearValues\r\n        get() = { }\r\n        set(value) {\r\n            editMe {\r\n                it.clear()\r\n            }\r\n        }\r\n}\r\n\r\n\r\n<\/code><\/pre>\n<p>Kotlin Android Extensions\u306e\u304a\u304b\u3052\u3067\u3001XML\u306e\u5404\u30d3\u30e5\u30fc\u306bfindViewById\u3092\u4f7f\u308f\u306a\u304f\u3066\u3082\u6e08\u307f\u307e\u3059\u3002\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001object\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u3063\u3066\u30b7\u30f3\u30b0\u30eb\u30c8\u30f3\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002editMe()\u3068\u3044\u3046\u540d\u524d\u306e\u30a4\u30f3\u30e9\u30a4\u30f3\u306e\u9ad8\u968e\u95a2\u6570\u3092\u5ba3\u8a00\u3057\u3066\u304a\u308a\u3001\u305d\u306e\u4e2d\u306b\u7de8\u96c6\u64cd\u4f5c\u306e\u30ed\u30b8\u30c3\u30af\u304c\u3042\u308a\u307e\u3059\u3002\u5404\u5024\u306e\u305f\u3081\u306b\u5225\u3005\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002\u5171\u6709\u30d7\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u5185\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u304a\u3088\u3073\u8a2d\u5b9a\u3059\u308b\u305f\u3081\u306b\u3001get\u304a\u3088\u3073set Kotlin\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002Kotlin\u306f\u30b3\u30fc\u30c9\u306e\u5197\u9577\u6027\u3092\u524a\u6e1b\u3057\u3001\u3088\u308a\u304d\u308c\u3044\u306b\u898b\u3048\u307e\u3059\u3002\u3055\u3089\u306b\u3001\u4ee5\u4e0b\u306b\u793a\u3059\u5225\u306eKotlin\u306e\u9ad8\u968e\u95a2\u6570\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u7c21\u6f54\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>fun SharedPreferences.Editor.put(pair: Pair&lt;String, Any&gt;) {\r\n    val key = pair.first\r\n    val value = pair.second\r\n    when(value) {\r\n        is String -&gt; putString(key, value)\r\n        is Int -&gt; putInt(key, value)\r\n        is Boolean -&gt; putBoolean(key, value)\r\n        is Long -&gt; putLong(key, value)\r\n        is Float -&gt; putFloat(key, value)\r\n        else -&gt; error(\"Only primitive types can be stored in SharedPreferences\")\r\n    }\r\n<\/code><\/pre>\n<p>\u5024\u3092\u8a2d\u5b9a\u3059\u308b\u9593\u306b\u3001\u79c1\u305f\u3061\u306f\u4ee5\u4e0b\u306e\u3053\u3068\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>var SharedPreferences.password\r\n        get() = getString(USER_PASSWORD, \"\")\r\n        set(value) {\r\n            editMe {\r\n                it.put(USER_PASSWORD to value)\r\n            }\r\n        }\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649f20daa94e2bdf7c2374\/28-0.gif\" alt=\"android shared preferences kotlin app output\" \/><\/div>\n<p>\u4ee5\u4e0b\u306e\u30ea\u30f3\u30af\u304b\u3089\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059: AndroidlySharedPreferences<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001Kotlin\u3092\u4f7f\u7528\u3057\u3066Android\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067SharedPreferences\u3092\u5b9f\u88c5\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u5b66\u3073\u307e\u3059\u3002 Android\u306eSharedPreferences\u3068\u306f\u4f55\u3067\u3059\u304b\uff1f Shar [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[26,61],"class_list":["post-855","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-26","tag-61"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Kotlin\u3092\u4f7f\u7528\u3057\u305fAndroid\u306eSharedPreferences - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"Kotlin\u3092\u4f7f\u7528\u3057\u305fAndroid\u306eSharedPreferences\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/ja\/blog\/kotlin\u3092\u4f7f\u7528\u3057\u305fandroid\u306esharedpreferences\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Kotlin\u3092\u4f7f\u7528\u3057\u305fAndroid\u306eSharedPreferences\" \/>\n<meta property=\"og:description\" content=\"Kotlin\u3092\u4f7f\u7528\u3057\u305fAndroid\u306eSharedPreferences\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/ja\/blog\/kotlin\u3092\u4f7f\u7528\u3057\u305fandroid\u306esharedpreferences\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-30T21:36:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-31T18:02:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649f20daa94e2bdf7c2374\/11-0.png\" \/>\n<meta name=\"author\" content=\"\u967d, \u5411\u5b87\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u967d, \u5411\u5b87\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"17\u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/kotlin%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9fandroid%e3%81%aesharedpreferences\/\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/kotlin%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9fandroid%e3%81%aesharedpreferences\/\",\"name\":\"Kotlin\u3092\u4f7f\u7528\u3057\u305fAndroid\u306eSharedPreferences - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\"},\"datePublished\":\"2022-09-30T21:36:06+00:00\",\"dateModified\":\"2025-07-31T18:02:57+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/4aef6196128551a0f5d66db46c42866c\"},\"description\":\"Kotlin\u3092\u4f7f\u7528\u3057\u305fAndroid\u306eSharedPreferences\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/kotlin%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9fandroid%e3%81%aesharedpreferences\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/ja\/blog\/kotlin%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9fandroid%e3%81%aesharedpreferences\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/kotlin%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9fandroid%e3%81%aesharedpreferences\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/ja\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Kotlin\u3092\u4f7f\u7528\u3057\u305fAndroid\u306eSharedPreferences\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"ja\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/4aef6196128551a0f5d66db46c42866c\",\"name\":\"\u967d, \u5411\u5b87\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ad96b120e219751fa368cbd7d2c48ca01b59185e6ed394449bac72614a760bf3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ad96b120e219751fa368cbd7d2c48ca01b59185e6ed394449bac72614a760bf3?s=96&d=mm&r=g\",\"caption\":\"\u967d, \u5411\u5b87\"},\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/author\/hinatasora\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/kotlin%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9fandroid%e3%81%aesharedpreferences\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Kotlin\u3092\u4f7f\u7528\u3057\u305fAndroid\u306eSharedPreferences - Blog - Silicon Cloud","description":"Kotlin\u3092\u4f7f\u7528\u3057\u305fAndroid\u306eSharedPreferences\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/ja\/blog\/kotlin\u3092\u4f7f\u7528\u3057\u305fandroid\u306esharedpreferences\/","og_locale":"ja_JP","og_type":"article","og_title":"Kotlin\u3092\u4f7f\u7528\u3057\u305fAndroid\u306eSharedPreferences","og_description":"Kotlin\u3092\u4f7f\u7528\u3057\u305fAndroid\u306eSharedPreferences\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","og_url":"https:\/\/www.silicloud.com\/ja\/blog\/kotlin\u3092\u4f7f\u7528\u3057\u305fandroid\u306esharedpreferences\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2022-09-30T21:36:06+00:00","article_modified_time":"2025-07-31T18:02:57+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/65649f20daa94e2bdf7c2374\/11-0.png"}],"author":"\u967d, \u5411\u5b87","twitter_card":"summary_large_image","twitter_misc":{"\u57f7\u7b46\u8005":"\u967d, \u5411\u5b87","\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593":"17\u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/ja\/blog\/kotlin%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9fandroid%e3%81%aesharedpreferences\/","url":"https:\/\/www.silicloud.com\/ja\/blog\/kotlin%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9fandroid%e3%81%aesharedpreferences\/","name":"Kotlin\u3092\u4f7f\u7528\u3057\u305fAndroid\u306eSharedPreferences - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website"},"datePublished":"2022-09-30T21:36:06+00:00","dateModified":"2025-07-31T18:02:57+00:00","author":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/4aef6196128551a0f5d66db46c42866c"},"description":"Kotlin\u3092\u4f7f\u7528\u3057\u305fAndroid\u306eSharedPreferences\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/kotlin%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9fandroid%e3%81%aesharedpreferences\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/ja\/blog\/kotlin%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9fandroid%e3%81%aesharedpreferences\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/ja\/blog\/kotlin%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9fandroid%e3%81%aesharedpreferences\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/ja\/blog\/"},{"@type":"ListItem","position":2,"name":"Kotlin\u3092\u4f7f\u7528\u3057\u305fAndroid\u306eSharedPreferences"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website","url":"https:\/\/www.silicloud.com\/ja\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"ja"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/4aef6196128551a0f5d66db46c42866c","name":"\u967d, \u5411\u5b87","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ad96b120e219751fa368cbd7d2c48ca01b59185e6ed394449bac72614a760bf3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ad96b120e219751fa368cbd7d2c48ca01b59185e6ed394449bac72614a760bf3?s=96&d=mm&r=g","caption":"\u967d, \u5411\u5b87"},"url":"https:\/\/www.silicloud.com\/ja\/blog\/author\/hinatasora\/"},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/kotlin%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9fandroid%e3%81%aesharedpreferences\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/855","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/comments?post=855"}],"version-history":[{"count":1,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/855\/revisions"}],"predecessor-version":[{"id":45865,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/855\/revisions\/45865"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/media?parent=855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/categories?post=855"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/tags?post=855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}