I have 2 columns in sqlite which are name and date,name is already set it to unique to avoid duplicate entry but my problem is I want to insert the same record for column 'name' but different record in column 'date'. I'm also using this to filter the duplicate record and it worked.
try {
dbOpenHelperss.insertOrThrow("table", values);
} catch (SQLiteConstraintException e)
//to detect if there is a duplicated item
}
For example in column_name='Peter Xavier' column_date='02/15/14 and i want to insert record of Peter Xavier with different date like column_name ='Peter Xavier' , column_date='02/16/14
What I tried so far is
if(!"column_date".equals(colum_name)) {
//to compare two columns are not the same then insert
ContentValues values = new ContentValues();
values.put("column_name",name );
values.put("column_date", date);
try {
dbOpenHelperss.insertOrThrow("table", values);
} catch (SQLiteConstraintException e) {
// to detect if there is a duplicate entry
}
}