I’m trying to insert values using ContentValues, I’ve inserted 5 values to 5 columns After I run the application, I’ve only the row with last set of values of ContentValues. The first four set is not inserted.
ContentValues cv = new ContentValues();
cv.put("name", "Cs Tech");
cv.put("name", "Wipro");
cv.put("name", "TCS");
cv.put("name", "Infosys");
cv.put("name", "Cognizant");
cv.put("mail", "joe@info.com");
cv.put("mail", "bru@wipro.com");
cv.put("mail", "jen@tcs.com");
cv.put("mail", "ram@infosys.com");
cv.put("mail", "cts@cts.com");
cv.put("contact", "180 151 2010");
cv.put("contact", "180 151 2011");
cv.put("contact", "180 151 2012");
cv.put("contact", "180 151 2013");
cv.put("contact", "180 151 2014");
cv.put("date", "27 Jul 2011");
cv.put("date", "27 Jul 2011");
cv.put("date", "27 Jul 2011");
cv.put("date", "27 Jul 2011");
cv.put("date", "27 Jul 2011");
this.db.insert(TABLE_NAME, "name", cv);
It is not hard to understand that
ContentValuesis some kind of a hashtable which implies that this peice of codeis ultimately overwriting the Value with key=”name” 4 times and name is finally getting the last value!
For this to work, you should do it sequentially like this: