Android-SharedPreferences detailed usage

Directory SharedPreferences 1. Introduction 2. Understand 1 data storage 2 Data reading 3 common methods 3.1 getSharedPreferences() 3.2 edit() 3.4 remove() remove data 3.5 clear() clears data 3.6 commit() submits and saves data 3. Basic use 1 an example 4. Monitoring 5. Performance analysis 6. Points of attention during use 1 Get the SharedPreferences object […]

Android source code analysis: Analysis of SharedPreferences

Android source code analysis: Analysis of SharedPreferences Introduction SharedPreferences is a lightweight data persistence method in Android. It may also be the first special local data persistence method we come into contact with when learning Android. This article will analyze the principle of SharedPreferences from the source code perspective. Source code analysis Generally we use […]

SharedPreferences stores small amounts of application configuration data

SharedPreferences are a simple way in Android to store small amounts of application configuration data. SharedPreferences is a mechanism for lightweight data storage on the Android platform. It provides simple methods to save and get basic types of data, such as boolean, float, int, long and string. Note: SharedPreferences does not support storing large amounts […]

Reflection to modify other APP SharedPreferences data

Reflection to modify other APP SharedPreferences data Prerequisites Available codes Prerequisite The device is rooted, otherwise the data/data directory cannot be accessed Problem symptoms: HIE_Find(com.estrongs.android.pop) APP can directly open the usb storage device, but the usb device node name changes after each plug and unplug, and the last opened path will always be remembered when […]

Performance Optimization: How to Completely Solve the Caton Caused by SharedPreferences

Background After launching the ANR monitoring platform, a lot of ANR logs have been collected online. From the flame graph information, the function is blocked on QueuedWork related functions. This article mainly introduces the reasons for this phenomenon and how to solve this problem. The solution introduced in this article has been put on github […]

android jetpack DataStore (java) instead of SharedPreferences

Table of Contents How to use Preferences DataStore? import dependencies Create a Preferences DataStore read content write content How to use Proto DataStore? import dependencies create proto Create a Serializer Use DataStore DataStore provides two different implementations: Preferences DataStore and Proto DataStore. Preferences DataStore stores and accesses data using keys Proto DataStore stores data as […]

Android experiment nine – use SharedPreferences to store simple data

Complete the following procedures (the main Activity interface is shown in Figure 1): Click the “Parameter Settings” button in Figure 1 to start the Activity shown in Figure 2. After the user enters the user name in Figure 2, click the “OK” button to close the Activity (you need to use SharedPreferences.Editor Save the username), […]

NeoPreference: a tool to simplify the use of SharedPreferences

Project address: https://github.com/Nagi1225/NeoPreference After a while, I found that many people read the previous article “A Simple, Elegant and Safe Usage of SharedPreferences”, so I fixed some problems, organized the code, and published it to jitpack for easy use. This article is the previous summary, induction and optimization. For the thinking process, you can refer […]

Mobile application development technology – SharedPreferences storage

Front-end XML <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical” android:background=”@color/teal_200″ android:padding=”10dp” tools:context=”.MainActivity”> <ImageView android:layout_width=”70dp” android:layout_height=”70dp” android:src=”@drawable/head” android:layout_gravity=”center_horizontal” android:layout_marginTop=”30dp” /> <RelativeLayout android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_marginTop=”15dp” android:background=”@color/white”> <TextView android:id=”@ + id/tv_username” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”Account:” android:layout_marginLeft=”10dp” android:layout_centerVertical=”true” android:textColor=”@color/black” android:textSize=”20sp”/> <EditText android:id=”@ + id/username” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_toEndOf=”@ + id/tv_username” android:layout_marginStart=”15dp” android:padding=”10dp” /> </RelativeLayout> <RelativeLayout android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:background=”@color/white”> […]