Android 永久保存简单数据
2024-08-24 17:40:27
转载: http://blog.csdn.net/xzlawin/article/details/45959033
方法1:
存数据:
SharedPreferences userInfo = this.getSharedPreferences("user_info", 0);
userInfo.edit().putString("name", nameet.getText().toString()).commit();
userInfo.edit().putString("password", passwordet.getText().toString()).commit();
读数据
SharedPreferences userInfo = this.getSharedPreferences("user_info", 0);
nameet.setText(userInfo.getString("name", ""));
passwordet.setText(userInfo.getString("password", ""));
方法2:
存数据:
SharedPreferences setting = getSharedPreferences("setting", 0);
SharedPreferences.Editor editor = setting.edit();
editor.putString("apiUrl", "hello").commit();
读数据
SharedPreferences setting = getSharedPreferences("setting", 0);
String apiUrl=setting.getString("apiUrl","");
最新文章
- DIV的Position属性和DIV嵌套DIV
- Python之路-python(mysql介绍和安装、pymysql、ORM sqlachemy)
- LoadRunner之篇
- eclipse提示:This tag and its children can be replaced by one <;TextView/>; and a compound drawable
- SQL复杂查询和视图
- ML 04、模型评估与模型选择
- 编译内核,配置内核make menuconfig
- (转)rabbitMQ基础知识及命令语句
- .Net Core 部署到IIS
- 串口接收端verilog代码分析
- Python 成仙之路
- BR(BoomerangRobot)机器人项目
- 7.Solr查询参数
- AS3 注意点
- hdoj1180 诡异的楼梯(bfs+奇偶判断)
- 【BZOJ4872】【Shoi2017】分手是祝愿
- 使用postman做接口测试(一)
- Ubuntu下的apache2的配置过程
- python 数据分析----matplotlib
- BZOJ2152 聪聪可可 【点分治】