这个代码是第一行代码的源码,在login里面存入键值对,原因是必须先点按钮登陆以后才会有选择能否密码,所以会创建remember_password,暂且这么理解吧。但是这样的顺序也可以吗,程序运行时候不会先执行boolean isremember那句报错吗,代码截图如下,新手党,求指点啊





解决方案
5
不会有错误啊,ShareP…假如里面没有那个remenber_password的键值对的话会返回定义的默认值,就是false
15
sharedPreferences 获取key-value时,假如无key或无value会返回默认的值,如你的getBoolean方法,可以看它的注解