SharedPreferences的工具类,使用起来方便.快捷:上代码:import android.content.Context;import android.content.SharedPreferences;/** * SharedPreferences的一个工具类,调用setData就能保存String, Integer, Boolean, Float, Long类型的参数 * 同样调用getData就能获取到保存在手机里面的数据 * * @author smiling * @date…
我们平常保存一些数据,都会用到SharedPreferences,他是保存在手机里面的,具体路径是data/data/你的包名/shared_prefs/保存的文件名.xml, SharedPreferences的使用也很简单,我自己就写了一个SharedPreferences的工具类,然后就保存在这里,等自己以后需要保存数据直接从这里copy代码,哈哈 工具类如下 package com.example.shortcut; import android.content.Context; imp…
import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; /** * SharedPreferences的工具类 * @author wangfubin */ public class Sp { private static String name = "config"; /** * 获取Shared…
/* * Copyright (C) 2014 Jason Fang ( ijasonfang@gmail.com ) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http…
import android.app.Activity; import android.content.Context; import android.content.ContextWrapper; import android.content.SharedPreferences; import com.imageviewpager.language.MyApplication; import java.io.File; import java.lang.reflect.Field; impor…
相信Android的这个最简单的存储方式大家都很熟悉了,但是有一个小小技巧,也许你没有用过,今天就跟大家分享一下,我们可以把SharedPreferences封装在一个工具类中,当我们需要写数据和读数据的时候,就可以直接通过工具类的set和get方法来完成,类似JavaBean,这样使用起来就比较方便,快捷(建议项目中使用次数比较多使用).好了,直接看看这段简单的代码吧: public class SharePreferenceUtil { private SharedPreferences s…
Android快捷便利但不常被使用的原生工具类 Android SDK原生 API中,有一些常用的工具类,运用得当可以省事省力省时,何况还是Android官方提供的,现在收集整理一些出来.DateUtils Android本身提供的日期时间工具类,里面有很多实用的工具集合.比如DateUtils.isToady()判断传入的日期时间是否为当天.getRelativeTimeSpanString可以计算时间间隔比如"几天前","几个月前",等等.DateUtils.f…
Android 中替代 sharedpreferences 工具类的实现 背景 想必大家一定用过 sharedpreferences 吧!就我个人而言,特别讨厌每次 put 完数据还要 commit.对 我就是这么懒!哈哈.另外,sharedpreferences 不能存类,集合和bitmap等数据!这点也让人非常不爽啊!所以,我就在这个美好的星期天撸了名为 SHARE 的工具类用来替代 sharedpreferences. 项目介绍 整体架构 先来看一下,整体架构图(画的不好请大家见谅): 从…
移动互联网时代,基于手机端的各种活动扫码和收付款码层出不穷:那我们如何在Java中生成自己想要的二维码呢?下面就来讲讲在Java开发中使用 google.zxing 生成二维码. 一般情况下,Java生成二维码的方式有三种,一种是基于 google.zxing ,是google公司出的:一种是基于 jp.sourceforge.qrcode ,日本一家公司开发的:还有一种是基于 jquery.qrcode.js 的 jquery 插件.比较常用的是 google.zxing 的方式,这里我们就以…
Android-JSONUtil工具类 常用的Json工具类,包含Json转换成实体.实体转json字符串.list集合转换成json.数组转换成json public class JSONUtil { private static final String TAG = JSONUtil.class.getSimpleName(); private JSONUtil(){} private static Gson gson = new Gson(); /** * 传入一个头部,获取头部管控中的所…