当前位置:网站首页>SharedPreferences data storage
SharedPreferences data storage
2022-07-23 16:04:00 【shuo277】
SharedPreferences
file , analogy .properties file , Data storage uses key value pairs to store
function
Write and read
What data can be put into SharedPreferences?
Original basic data , Composite data is not allowed
boolean float int long String
How to get SharedPreferences?
SharedPreferences sp = getSharedPreferences( Parameters 1, Parameters 2) Parameters 1: Storage file name Parameters MODE_PRIVATE Pattern
The process of writing ?
// 1 obtain SharedPreferencesSharedPreferences sp=getSharedPreferences("loginfo",MODE_PRIVATE);// 2 With the help of EditorSharedPreferences.Editor edit = sp.edit();// 3 Write dataedit.putString("user",user); edit.putString("pwd",pwd);// 4 Submit dataedit.commit();
The process of reading ?
// 1 obtain SharedPreferencesSharedPreferences sp=getSharedPreferences("loginfo",MODE_PRIVATE); // 2 according to key To get the valueString user1 = sp.getString("user", ""); String pwd1 = sp.getString("pwd", "");
Case study : The login function of account and password can be backfilled
1.java file

2.xml file

边栏推荐
- Mathematical Modeling Typesetting
- PHP code audit 4 - SQL injection vulnerability
- Please initialize the log4j system properly.
- MD5 strong collision, secondary decoding,
- Self capacitance touch controller for wearable devices it7259q-13, it7259ex-24
- 【论文学习】《Source Mixing and Separation Robust Audio Steganography》
- Jianzhi offer II 115. reconstruction sequence: topological sorting construction problem
- After Effects 教程,如何在 After Effects 中创建动画?
- MySQL-字符串按照数值排序
- aws篇4 一机一密
猜你喜欢

Remember SQL optimization once

一个悄然崛起的国产软件,太强了!

Bubble sort - just read one

后缀表达式(暑假每日一题 4)

Safe and reasonable use of electricity to harvest a cool "summer"

中年危机,35岁被退休,打工人拿什么来抗衡资本家?

2022最NB的JVM基础到调优笔记,吃透阿里P6小case

Custom encapsulation pop-up box (with progress bar)

Software testing weekly (No. 81): what can resist negativity is not positivity, but concentration; What can resist anxiety is not comfort, but concrete.

關於初始化page入參的設計思路
随机推荐
Gear 月度更新|6 月
Translucenttb recommendations
Suffix expression (summer vacation daily question 4)
可穿戴设备的自电容触摸控制器IT7259Q-13,IT7259EX-24
Redis master-slave replication
重磅 | CertiK:2022年第二季度Web3.0行业安全报告发布(附PDF下载链接)
什么是真正的 HTAP ?(二)挑战篇
SCA在得物DevSecOps平台上应用
Learning about patents
sqlnet. Ora-12154 and ora-01017 connection exceptions caused by incorrect ora file settings
冒泡排序-看着一篇就够啦
ESP8266 NodeMCU 闪存文件系统(SPIFFS)
day1
[attack and defense world web] difficulty Samsung 9 points introductory question (Part 2): shrink, lottery
【云原生】持续集成和部署(Jenkins)
946. 验证栈序列 ●● & 剑指 Offer 31. 栈的压入、弹出序列 ●●
The difference between cookies and sessions
数字化转型时代的企业数据新基建 | 爱分析报告
aws篇6 aws iot
md5强碰撞,二次解码,