/** * Insert chatter. * * @param chatter the chatter * @return the long */ public long insertChatter(Chatter chatter) { this.insertChatter.bindString(1, chatter.getChatterId()); this.insertChatter.bindString(2, chatter.getActor()); this.insertChatter.bindString(3, chatter.getPost()); this.insertChatter.bindLong(4, chatter.getCommentCount()); this.insertChatter.bindLong(5, chatter.getLikeCount()); this.insertChatter.bindLong(6, System.currentTimeMillis()); return this.insertChatter.executeInsert(); }
/** * Update data. * * @param chatter the chatter */ public void updateChatter(Chatter chatter) { ContentValues vals = new ContentValues(); vals.put("chatterId", chatter.getChatterId()); vals.put("actor", chatter.getActor()); vals.put("post", chatter.getPost()); vals.put("commentCount", chatter.getCommentCount()); vals.put("likeCount", chatter.getLikeCount()); vals.put("createTime", System.currentTimeMillis()); this.db.update(TABLE_CHATTER, vals, "id=" + chatter.getId(), null); }
/** * Select all data. * * @return the list of Items */ public Map<String, Chatter> selectAllChatterMap() { Map<String, Chatter> map = new HashMap<String, Chatter>(); Cursor cursor = this.db.rawQuery("SELECT * FROM " + TABLE_CHATTER, null); if (cursor.moveToFirst()) { do { Chatter c = new Chatter(); c.setId(cursor.getLong(0)); c.setChatterId(cursor.getString(1)); c.setActor(cursor.getString(2)); c.setPost(cursor.getString(3)); c.setCommentCount(cursor.getInt(4)); c.setLikeCount(cursor.getInt(5)); c.setCreateTime(cursor.getLong(6)); map.put(c.getChatterId(), c); } while (cursor.moveToNext()); } if (cursor != null && !cursor.isClosed()) { cursor.close(); } return map; }