private void insertImgUrls() { LinkedList<ImgUrl> imgUrls = ImgUrl.getImgUrls(this); if (null != imgUrls) { ImgUrlDaoImpl imgUrlDao = new ImgUrlDaoImpl(new DBHelper(this)); boolean returnFlag = imgUrlDao.insertImgUrls(imgUrls); returnFlag = true; // 执行完成 mPreferences.edit().putBoolean(PREF_FIRST_INSERT_IMG_URL, returnFlag).commit(); if (returnFlag) { System.out.println("插入图片Base URL 成功"); } else { System.out.println("插入图片Base URL 失败"); } } }
public boolean isImg(String str) { ImgUrlDaoImpl imgUrlDao = new ImgUrlDaoImpl(new DBHelper(this)); List<String> imgList = imgUrlDao.getImgUrls(); boolean flag = false; for (String string : imgList) { if (str.startsWith(string)) { flag = true; break; } else if (str.toLowerCase(Locale.getDefault()).endsWith(".png") || str.toLowerCase(Locale.getDefault()).endsWith(".jpg") || str.toLowerCase(Locale.getDefault()).endsWith(".jpeg") || str.toLowerCase(Locale.getDefault()).endsWith("gif")) { flag = true; break; } } return flag; }