之前测试读取sd卡的图片,如果sd卡没有此图片则要通过网络去获取,判断为空的时候一直有问题
最后终于解决,原来又是equals 和 == 的区别
原来的方法
public static Drawable readPicFromSD(String shortPath) {
String path = getSDPath();
path = path + "/ydxy/" + shortPath;
Bitmap bit = BitmapFactory.decodeFile(path);
Drawable drawable = new BitmapDrawable(bit);
if (bit equals (null)) {
return null;
}
return drawable;
}
public static Drawable readPicFromSD(String shortPath) {
String path = getSDPath();
path = path + "/ydxy/" + shortPath;
Bitmap bit = BitmapFactory.decodeFile(path);
Drawable drawable = new BitmapDrawable(bit);
if (bit==null) {
return null;
}
return drawable;
}