1
删除重复值有一个HashMap和我使用同样的keys.I要inser在数据库中的值,只有当该值不存在DATABSE在HashMap中输入值。我如何在HashMap中
这里是我的代码
s11=json_data.getString("phno");
Iterator myVeryOwnIterator = map.keySet().iterator();
while(myVeryOwnIterator.hasNext()) {
String key=(String)myVeryOwnIterator.next();
String value=(String)map.get(key);
if(s11.compareTo(value)==0)
{//String name2 = cursor.getString(cursor.getColumnIndex(s11));
queryValues.put("c",value);
//Cursor cursr = contentResolver.query(PhoneCONTENT_URI, null, Phone_CONTACT_ID + " = ?", new String[] { s11 }, null);
// Toast.makeText(getActivity(),"get particular name", Toast.LENGTH_LONG).show();
db.insertcontact(queryValues);
// Toast.makeText(getActivity(),"true", Toast.LENGTH_LONG).show();
}
}
我建议重写equals方法到您的类,并且 – meh
之前添加值到HashMap中使用的方法包含(OBJ)之前,我会建议使用的HashSet您的需求的http://计算器。 com/questions/15579863 /使用hashset-over-hashmap的优点http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util /HashSet.java – Gattsu