保存
List<IndustryListEntity> indutryEntityList = new ArrayList<>();//行业id 名称 还有很多 indutryEntityList.addAll(FastJsonUtils.getObjectsList(t.getData(), IndustryListEntity.class)); for (int i = 0; i < indutryEntityList.size(); i++) { industryId = String.valueOf(indutryEntityList.get(i).getIndustryId());//把数字变成String 行业id String industryNm = indutryEntityList.get(i).getIndustryNm();//行业名称 SharedPreferences sharedPreferences = getSharedPreferences("industryInfo", Context.MODE_PRIVATE); //私有数据 SharedPreferences.Editor editor = sharedPreferences.edit();//获取编辑器 editor.putString(industryNm, industryId);//名称 id editor.putString(industryId, industryNm);//id 名称 editor.commit();//提交修改 industryList.add(industryNm);//行业id 行业名称 获取最终行业名称列表
}
读取
SharedPreferences share = getSharedPreferences("industryInfo", Activity.MODE_PRIVATE); String industryOne = share.getString(item, "");//名称 获取id