/** * Insert data. * * @param comment the comment * @return the number of inserted */ public long insertComment(Comment comment) { this.insertComment.bindString(1, comment.getChatterId()); this.insertComment.bindString(2, comment.getCommentId()); this.insertComment.bindString(3, comment.getAuthor()); this.insertComment.bindString(4, comment.getBody()); return this.insertComment.executeInsert(); }
/** * Select all data. * * @return the list of Items */ public Map<String, Comment> selectAllCommentMap() { Map<String, Comment> map = new HashMap<String, Comment>(); Cursor cursor = this.db.rawQuery("SELECT * FROM " + TABLE_COMMENTS, null); if (cursor.moveToFirst()) { do { Comment c = new Comment(); c.setChatterId(cursor.getString(1)); c.setCommentId(cursor.getString(2)); c.setAuthor(cursor.getString(3)); c.setBody(cursor.getString(4)); map.put(c.getCommentId(), c); } while (cursor.moveToNext()); } if (cursor != null && !cursor.isClosed()) { cursor.close(); } return map; }