80,471
社区成员




第一种: String userIconPath = FileManager.getUserHeadPath(config.getSchoolId(),config.getUserTel()+"/"+config.getUserId()+"userIcon.png");
if(new File(userIconPath).exists())
{
Log.e("头像未被设置",userIconPath);
headIcon.setImageBitmap(FileManager.getBitmap(context));
}
第一种的效果是:新建了一个名为“3userIcon.png”的文件夹.
第二种:String userIconPath = FileManager.getUserHeadPath(config.getSchoolId(), config.getUserTel());
String iconPath = userIconPath+"/"+config.getUserId()+"userIcon.png";
//服务端请求头像的数据,本地存在从本地取,否则,从服务器下载下来再再本地取
if(new File(iconPath).exists())
{
Log.e("头像未被设置",userIconPath);
headIcon.setImageBitmap(FileManager.getBitmap(context));
}
第二种的效果是并不新建“3userIcon.png”,只有在new File(iconPath).createNewFile();才新建“3userIcon.png”的图片,注意:是图片
可能和FileManager.getUserHeadPath这个方法有关,但是我找不到原因
public static final String getUserHeadPath(int schoolId, String account) {
if (hasSdcard()) {
File path = new File(FileManager.USER_HEAD_BASE + "/" + schoolId
+ "_" + account);
if (!path.exists()) {
path.mkdirs();
}
return FileManager.USER_HEAD_BASE + "/" + schoolId + "_" + account;
}
return null;
}