private long addH_article(String title, String link, byte[] imageByteStream) { Log.e("addH_article", "HERE NOW!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); long _id = 0; // Query database to see if article exists Cursor c = getH_articleLINK(link); try { // Insert H_articleEntry if not found if (c.getCount() == 0) { ContentValues articleValues = new ContentValues(); articleValues.put(H_articleEntry.COLUMN_TITLE, title); articleValues.put(H_articleEntry.COLUMN_LINK, link); articleValues.put(H_articleEntry.COLUMN_IMAGEBYTESTREAM, imageByteStream); _id = H_articleEntry.getIndexFromUri( mCWrapper.getContentResolver().insert(H_articleEntry.CONTENT_URI, articleValues)); Log.e("addH_article", "Article getting inserted~~~~~~~~~~~~~~~"); } // Or just return _id of existing row else { _id = c.getLong(c.getColumnIndex(H_articleEntry._ID)); Log.e("addH_article", "Article already inserted~~~~~~~~~~~~~~~"); } } finally { if (c != null) c.close(); } return _id; }
private Cursor getH_articleID(long _id) { return mCWrapper .getContentResolver() .query( H_articleEntry.CONTENT_URI, null, H_articleEntry._ID + "=?", new String[] {Long.toString(_id)}, null); }
private Cursor getH_articleLINK(String link) { return mCWrapper .getContentResolver() .query( H_articleEntry.CONTENT_URI, null, H_articleEntry.COLUMN_LINK + "=?", new String[] {link}, null); }