Android使用SharedPreferences进行数据存储,缓存ID等数据

存储数据

SharedPreferences sharedPre = getSharedPreferences("idpath", MODE_PRIVATE);
SharedPreferences.Editor editor=sharedPre.edit();
editor.commit();

获取存储的数据

SharedPreferences sharedPre=getSharedPreferences("idpath", MODE_PRIVATE);
String getID=sharedPre.getString("authid", "");

Demo地址https://github.com/han103070/SaveId

猜你喜欢

转载自blog.csdn.net/qq_37980878/article/details/82352310
今日推荐