java - how to insert unique values in database -



java - how to insert unique values in database -

i using next method insert name in database

public void insertcontact(string name) { contentvalues newcontact = new contentvalues(); newcontact.put("name", name); open(); // open database database.insert("contacts", null, newcontact); close(); // close database } // end method insertcontact

can made kind of check stop info duplication. mean if name exist in info base of operations should not insert new one.

the easiest way add together rule in database on table unique values on column. if seek add together duplicate value exception thrown.

see illustration set unique rule: http://www.w3schools.com/sql/sql_unique.asp

java android sql

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -