Shareprefences的使用
来源:互联网 发布:淘宝甩货文案 编辑:程序博客网 时间:2024/05/22 17:35
一般的轻量级数据库都用在登录上,所以设置成全局的救行
public class ImageLoader extends Application{ public static SharedPreferences sp; public static SharedPreferences.Editor edit; @Override public void onCreate() { super.onCreate(); sp = getSharedPreferences("user", MODE_PRIVATE); edit = sp.edit(); ImageLoaderConfiguration build = new ImageLoaderConfiguration.Builder(this).build(); com.nostra13.universalimageloader.core.ImageLoader.getInstance().init(build); }}
在AndroidManifest中注册:
android:name=".Adapter.ImageLoader"
用法:
//存入数据库ImageLoader.edit.putString("name","你要存储的数据");//给一个标识符,判断是否登录成功ImageLoader.edit.putBoolean("isLogin",true);//提交ImageLoader.edit.commit();//从数据库取出来//后面的false是默认如果为空,就为falseboolean isLogin = ImageLoader.sp.getBoolean("isLogin", false);
弹出框的做法:(和shareprefences)
//弹出框的做法:AlertDialog.Builder builder = new AlertDialog.Builder(context).setTitle("添加提示:").setMessage("是否加入购物车?").setPositiveButton("是", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { showShopClickInterface.ShopOnClickListen(list.get(position).getPid()); }}).setNeutralButton("否", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { }});builder.show();
阅读全文
1 0
- Shareprefences的使用
- Android使用Shareprefences模板
- 利用sharePrefences记录被点击的ListView
- Android数据存储方式之——Shareprefences
- GUID使用的使用
- ${}的使用
- 的使用
- @[],@()的使用
- ->的使用
- +、-、*、/、%的使用
- &&的使用
- %:的使用
- Makefile中使用$$的使用
- Makefile中使用$$的使用
- Red5的使用--使用日志
- prefernce的使用具体使用
- 【工具使用】git 的使用
- 关于使用AsyncTaskLoader的使用
- banner轮播
- 取消MFC的自动菜单折叠
- web项目中的路径
- linux系统编程学习day3--exec函数族
- 剑指offer-操作给定的二叉树,将其变换为源二叉树的镜像
- Shareprefences的使用
- Mutisim 的BJT电路仿真与分析
- 前端项目知识点整理-滚动加载更多
- find_first_of()和 find_last_of()
- scala编程02--变量
- Wannafly挑战赛3 C.位数差(树状数组)
- java.io 包
- UCOSII源码-信号量理解
- 接口 Closeable