private void updateImageForArticle(Article article) throws SQLException { try { List<String> html = executeHttpGet(Constants.pathToArticleDescription + article.getId()); LinkedList<String> possibleLinks = new LinkedList<String>(); Pattern pattern = Pattern.compile("\"[^\"]*.jpg"); for (String line : html) { Matcher m = pattern.matcher(line); while (m.find()) { String possibleLink = m.group().substring(1, m.group().length()); possibleLinks.add(possibleLink); } } if (possibleLinks.size() > 0) article.setImageUrl(possibleLinks.get(0)); else article.setImageUrl(""); } catch (Exception e) { Log.i("UpdataDatabase", "Couldn't get Sites html"); e.printStackTrace(); article.setImageUrl(""); } article.createOrUpdate(); }