③创建二维码文件存储目录
private static String getFileRoot(Context context) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { File external = context.getExternalFilesDir(null); if (external != null) { return external.getAbsolutePath(); } } return context.getFilesDir().getAbsolutePath(); }
④创建数据库工具类来存储临时数据
public class SPUtil { private static final String CONFIG = "config"; /** * 获取SharedPreferences实例对象 * * @param fileName */ private static SharedPreferences getSharedPreference(String fileName) { return QRCodeApplication.getInstance().getSharedPreferences(fileName, Context.MODE_PRIVATE); } /** * 保存一个String类型的值! */ public static void