{"id":85017,"date":"2021-09-28T09:00:41","date_gmt":"2021-09-28T03:30:41","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=85017"},"modified":"2024-08-15T20:53:31","modified_gmt":"2024-08-15T15:23:31","slug":"shared-preferences-in-android","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/shared-preferences-in-android\/","title":{"rendered":"Shared Preferences in Android"},"content":{"rendered":"<p>In this article, we will proceed with Android Preferences and Shared Preferences. Like any other android storage, android preferences and shared preferences are also used to store application data. What makes the android preference and shared preference storage different from others is the storing pattern. In Android and Shared Preference, data is stored in the form of key-value pairs.<\/p>\n<p>We will try to cover every aspect of Android Preference and Shared Preference through this article and demonstrate the same.<\/p>\n<h3>Preferences in Android<\/h3>\n<p>Preferences in Android are key-value pairs used to store user\u2019s data with the flow of the application. The data exists even after closing the application. However, the data gets removed when the user uninstalls or clears app data. Preferences are usually used to store data of small size.<\/p>\n<p>Preferences are pretty helpful while storing user details on the go. Suppose someone installed your application, and you want them to fill in their details before using the application. Now, these details like name, mobile number, address can be stored in the preferences and shown to the user whenever required.<\/p>\n<p>Usually, preferences support only primitive data types like as follows:<\/p>\n<ul>\n<li>Boolean Types<\/li>\n<li>Integer Types<\/li>\n<li>Float Types<\/li>\n<li>String Types<\/li>\n<li>Long Types<\/li>\n<\/ul>\n<p>Note: While storing data in preferences, you should ensure a unique key is assigned for each value. This key is later on used to fetch the data from the preferences.<\/p>\n<h3>APIs involved in accessing Preferences<\/h3>\n<p>Currently, we have three kinds of APIs that can be used to access preferences in any android application. These are:<\/p>\n<p><strong>1. getPreference()<\/strong> &#8211; The getPreference() method is used to access preferences that are specific to a single activity. This method retrieves the SharedPreferences object associated with the activity, allowing you to read or modify settings that are unique to that particular activity. This is useful for storing and managing preferences that are relevant only to the current activity&#8217;s lifecycle.<\/p>\n<p><strong>2. getSharedPreference()<\/strong> &#8211; The getSharedPreferences() method provides access to application-level preferences that can be shared across multiple activities within the same application. By specifying a unique name and mode, you can access a SharedPreferences instance that allows reading and writing data that is consistent across different activities and even different contexts within the application.<\/p>\n<p><strong>3. getDefaultSharedPreference()<\/strong> &#8211; The getDefaultSharedPreferences() method returns the default SharedPreferences instance used by the Android preference framework. This instance is shared across all activities and fragments within the application, providing a common storage area for preferences. It simplifies access to default preferences without requiring you to create and manage multiple SharedPreferences instances manually.<\/p>\n<h3>Shared Preferences in Android<\/h3>\n<p>Shared Preferences, as the name suggests, is a storage that is shared throughout your application. It implies that the key-value pairs stored as preferences are available to all the activities, fragments, and other application contexts present within the app. Shared Preferences of one app are limited to that app only, and other apps can\u2019t access it.<\/p>\n<p>To use Shared Preferences in a particular activity, we first need to get the instance of it. To get an example of it, we use the getSharedPreference() method as shown below.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">var sharedPrefObj: SharedPreferences? = null\r\nsharedPrefObj = getSharedPreferences(\"yourData\", MODE_PRIVATE)\r\n<\/pre>\n<p>We supplied two parameters to the procedure above: the name of the Shared Preference and the mode. The mode is set to Private by default. Instead of private, you have five distinct settings to choose from.<\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Mode Name<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">MODE_APPEND<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It is used to append new changes or new preferences to the existing preferences.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">MODE_ENABLE_WRITE_AHEAD _LOGGING<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It is used to maintain database consistency. It enables write-ahead logging that means that the changes are done locally before finally updating the database.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">MODE_WORLD_READABLE<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Using this mode, you can only read values from the preference and can\u2019t write to it.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">MODE_WORLD_WRITABLE<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Using this mode, you can write data to the preference.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">MODE_MULTI_PROCESS<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It is used when multiple processes try to access or modify the shared preferences at a time.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">MODE_PRIVATE<\/span><\/td>\n<td><span style=\"font-weight: 400;\">It is the default mode of shared preference and allows you to access files only when called.\u00a0<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Methods in Shared Preferences in Android<\/h3>\n<p>There are several methods involved in Shared Preferences that help us write, update and delete data in a shared preference.<\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Method Name<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">contains(key : String)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The contains() method takes the key of your data and then returns whether the key is present in the preferences.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">edit()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The edit() method is called by the SharedPreferences Editor to modify the existing data and then commit the changes back to preferences.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">getAll()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The getAll() provides us all the values present in the Shared Preferences.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">getBoolean(key :String, defValue : Boolean)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The getBoolean() method is used to get a boolean value corresponding to the key provided. If the key mismatches or if no value is found, then it returns the defValue.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">getString(key :String, defValue : String)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The getString() method is used to get a String value corresponding to the key provided. If the key mismatches or if no value is found, then it returns the defValue.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">getInt(key :String, defValue : Int)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The getInt() method is used to get an int value corresponding to the key provided. If the key mismatches or if no value is found, then it returns the defValue.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">getFloat(key :String, defValue : Float)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The getFloat() method is used to get a float value corresponding to the key provided. If the key mismatches or if no value is found, then it returns the defValue.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">getDouble(key :String, defValue : Double)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The getDouble() method is used to get a double value corresponding to the key provided. If the key mismatches or if no value is found, then it returns the defValue.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">getLong(key :String, defValue : Long)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The getLong() method is used to get a long value corresponding to the key provided. If the key mismatches or if no value is found, then it returns the defValue.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Preferences vs SharedPreferences in Android<\/h3>\n<p>Let us now understand how preferences are different from Shared Preferences.<\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Preferences<\/b><\/td>\n<td><b>Shared Preferences<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Preferences store data in implementation-dependent backing stores.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Shared Preferences store data in XML files.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Preferences data are highly encrypted and don\u2019t undergo any changes when the device is rebooted.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Shared Preferences data is not that highly encrypted and is subjected to change when the device restarts.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Preferences are a better option for sensitive data.\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Shared Preferences are not so good for sensitive data.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Preferences instance is created by the following:<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Shared Preferences is created by the following:<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Implementation of Shared Preferences in Android<\/h3>\n<p>I hope you got some idea about Shared Preferences and what its use is in android. Now, it\u2019s time for us to see a detailed implementation of Shared Preference in Android.<\/p>\n<p>We will be developing a straightforward app where I will be storing the name and mobile number of the user in Shared Preference and then close the app and see if the data still exists in the preference or not.<\/p>\n<p>Step 1: Start your Android Studio and create a new project called \u201cTechVidvanSharedPref.\u201d<\/p>\n<p>Step 2: Now locate your activity_main.xml file and paste the below code there.<\/p>\n<p><strong>Code: activity_main.xml<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;LinearLayout\r\n    xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    xmlns:app=\"http:\/\/schemas.android.com\/apk\/res-auto\"\r\n    xmlns:tools=\"http:\/\/schemas.android.com\/tools\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    android:orientation=\"vertical\"\r\n    tools:context=\".MainActivity\"&gt;\r\n\r\n   &lt;TextView\r\n       android:id=\"@+id\/title\"\r\n       android:layout_width=\"match_parent\"\r\n       android:layout_height=\"wrap_content\"\r\n       android:layout_marginTop=\"20dp\"\r\n       android:text=\"TechVidvan\"\r\n       android:textSize=\"40sp\"\r\n       android:gravity=\"center\"\r\n       android:layout_marginBottom=\"20dp\"\r\n       android:textColor=\"#4CAF50\"\r\n       \/&gt;\r\n\r\n    &lt;EditText\r\n        android:id=\"@+id\/yourName\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:hint=\"Enter your Name\"\r\n        android:textSize=\"20sp\"\r\n        android:layout_margin=\"20dp\"\r\n        android:padding=\"10dp\"\r\n        android:inputType=\"textCapWords\"\r\n        \/&gt;\r\n\r\n    &lt;EditText\r\n        android:id=\"@+id\/yourPhone\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:hint=\"Enter Mobile Number\"\r\n        android:textSize=\"20sp\"\r\n        android:inputType=\"phone\"\r\n        android:layout_margin=\"20dp\"\r\n        android:padding=\"10dp\"\r\n        \/&gt;\r\n\r\n    &lt;Button\r\n        android:onClick=\"SaveDataToPreference\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_gravity=\"center\"\r\n        android:layout_margin=\"30dp\"\r\n        android:text=\"Store Data to Preference\"\r\n        android:backgroundTint=\"@color\/black\"\r\n        \/&gt;\r\n\r\n    &lt;Button\r\n        android:onClick=\"showDataFromPreference\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_gravity=\"center\"\r\n        android:layout_margin=\"30dp\"\r\n        android:text=\"Show Data in Preference\"\r\n        android:backgroundTint=\"#4CAF50\"\r\n        \/&gt;\r\n&lt;\/LinearLayout&gt;\r\n<\/pre>\n<p>Step 3: Now locate your MainActivity.kt file and paste the below code.<\/p>\n<p><strong>Code: MainActivity.kt<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.techvidvan.techvidvansharedpref\r\n\r\nimport android.content.SharedPreferences\r\nimport android.os.Bundle\r\nimport android.view.View\r\nimport android.widget.EditText\r\nimport android.widget.Toast\r\nimport androidx.appcompat.app.AppCompatActivity\r\n\r\n\r\nclass MainActivity : AppCompatActivity()\r\n{\r\n    \/\/declaring variables of edit text\r\n\r\n    lateinit var nameEdit: EditText\r\n    lateinit var phoneEdit: EditText\r\n    var sharedPrefObj: SharedPreferences? = null\r\n\r\n    override fun onCreate(savedInstanceState: Bundle?)\r\n    {\r\n        super.onCreate(savedInstanceState)\r\n        setContentView(R.layout.activity_main)\r\n\r\n        \/\/binding the variables with the edit texts\r\n        nameEdit = findViewById(R.id.yourName)\r\n        phoneEdit = findViewById(R.id.yourPhone)\r\n\r\n\r\n        \/\/Calling the instance of shared preferences from this activity\r\n        sharedPrefObj = getSharedPreferences(\"yourData\", MODE_PRIVATE)\r\n\r\n    }\r\n\r\n    fun SaveDataToPreference(view: View)\r\n    {\r\n        \/\/Fetching the values from the Edit Text Field\r\n        val name = nameEdit.text.toString()\r\n        val phone = phoneEdit.text.toString()\r\n\r\n        \/\/Saving those values in the shared preferences\r\n        \/\/for this, we need to create an instance of\r\n        \/\/shared preferences editor as shown below\r\n\r\n        val editor: SharedPreferences.Editor = sharedPrefObj!!.edit()\r\n\r\n        \/\/Now since both of our data is string hence I will use putString() method\r\n        editor.putString(\"Name\", name)\r\n        editor.putString(\"Phone\", phone)\r\n\r\n        \/\/After doing the changes, we need to apply them to the preferences\r\n        \/\/This is a necessary step because if you don't apply, then\r\n        \/\/the changes won't reflect\r\n        editor.apply()\r\n    }\r\n    fun showDataFromPreference(view: View)\r\n    {\r\n        \/\/When user wants to see the data stored in preferences\r\n\r\n        \/\/Now let's fetch the data stored in preferences\r\n\r\n        val name = sharedPrefObj!!.getString(\"Name\", \"No Value\")\r\n        val phone = sharedPrefObj!!.getString(\"Phone\", \"No Value\")\r\n\r\n\r\n        \/\/Now, let's display the results to the user\r\n        Toast.makeText(this@MainActivity, \"Name : $name\\n Phone : $phone\",\r\n            Toast.LENGTH_LONG).show()\r\n    }\r\n}\r\n<\/pre>\n<p>Finally, run your application on your device or emulator and notice the output you got.<\/p>\n<p>The app is asking me to enter my name and phone number.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-85076\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/android-preferences-output1.jpg\" alt=\"android preferences\" width=\"350\" height=\"740\" \/><\/p>\n<p>After entering my name and phone number, I will click on the store button and close the application.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-85077\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/android-preferences-output2.jpg\" alt=\"android preferences output\" width=\"350\" height=\"740\" \/><\/p>\n<p>Now restart your application and click on show data. You can notice that the data was successfully stored in the shared preferences of your application.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-85078\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/09\/android-preferences-output3.jpg\" alt=\"android preferences\" width=\"350\" height=\"740\" \/><\/p>\n<h3>Summary<\/h3>\n<p>Through this article, you came across Preferences and Shared Preferences in Android. You came across the use and type of data it can store. You saw the several APIs to implement preferences in Android. Later on, you came across Shared Preferences and their methods. Moving further, you saw the differences between preferences and Shared Preferences. Finally, you saw an implementation of Shared Preferences in Android.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will proceed with Android Preferences and Shared Preferences. Like any other android storage, android preferences and shared preferences are also used to store application data. What makes the android preference&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":85075,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2791],"tags":[4309,3647,4373,4374],"class_list":["post-85017","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android","tag-android-preferences","tag-binary-search-implementation","tag-preferences-vs-sharedpreferences-in-android","tag-shared-preferences-in-android"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Shared Preferences in Android - TechVidvan<\/title>\n<meta name=\"description\" content=\"Learn Preferences &amp; Shared Preferences in Android. See use &amp; type of data it can store. See several APIs to implement preferences in Android.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/shared-preferences-in-android\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Shared Preferences in Android - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Learn Preferences &amp; Shared Preferences in Android. See use &amp; type of data it can store. See several APIs to implement preferences in Android.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/shared-preferences-in-android\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-09-28T03:30:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-08-15T15:23:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/09\/android-preference-shared-preference.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Shared Preferences in Android - TechVidvan","description":"Learn Preferences & Shared Preferences in Android. See use & type of data it can store. See several APIs to implement preferences in Android.","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:\/\/techvidvan.com\/tutorials\/shared-preferences-in-android\/","og_locale":"en_US","og_type":"article","og_title":"Shared Preferences in Android - TechVidvan","og_description":"Learn Preferences & Shared Preferences in Android. See use & type of data it can store. See several APIs to implement preferences in Android.","og_url":"https:\/\/techvidvan.com\/tutorials\/shared-preferences-in-android\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2021-09-28T03:30:41+00:00","article_modified_time":"2024-08-15T15:23:31+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/09\/android-preference-shared-preference.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/shared-preferences-in-android\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/shared-preferences-in-android\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Shared Preferences in Android","datePublished":"2021-09-28T03:30:41+00:00","dateModified":"2024-08-15T15:23:31+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/shared-preferences-in-android\/"},"wordCount":1327,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/shared-preferences-in-android\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/09\/android-preference-shared-preference.jpg","keywords":["Android Preferences","Binary Search Implementation","Preferences vs SharedPreferences in Android","Shared Preferences in Android"],"articleSection":["Android Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/shared-preferences-in-android\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/shared-preferences-in-android\/","url":"https:\/\/techvidvan.com\/tutorials\/shared-preferences-in-android\/","name":"Shared Preferences in Android - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/shared-preferences-in-android\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/shared-preferences-in-android\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/09\/android-preference-shared-preference.jpg","datePublished":"2021-09-28T03:30:41+00:00","dateModified":"2024-08-15T15:23:31+00:00","description":"Learn Preferences & Shared Preferences in Android. See use & type of data it can store. See several APIs to implement preferences in Android.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/shared-preferences-in-android\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/shared-preferences-in-android\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/shared-preferences-in-android\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/09\/android-preference-shared-preference.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/09\/android-preference-shared-preference.jpg","width":1200,"height":628,"caption":"android preference shared preference"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/shared-preferences-in-android\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Shared Preferences in Android"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/85017","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=85017"}],"version-history":[{"count":1,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/85017\/revisions"}],"predecessor-version":[{"id":447630,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/85017\/revisions\/447630"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/85075"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=85017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=85017"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=85017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}