google 推荐使用 apply()
SharedPreferences.Editor editor = sharedPreferences.edit();
//获取编辑器
editor.putString("UserID",userID);
editor.commit();//提交修改
初看这代码没什么问题
但是lint检测 发现google推荐使用 apply();
google 提示
Consider using apply() instead; commit writes its data to persistent storage immediately,
whereas apply will handle it in the background
考虑使用apply(); commit立即将其数据写入永久存储器,而apply将在后台处理它
项目而定 应该立即写入