I am fetching and storing phone numbers and contact names in a SQLite DB from an Android phone. Now my problem is that whenever I refresh/reload the app the SQL entries (phone and contacts) are inserted again and again giving rise to duplicate entries. How to stop this, I am using Phonegap, by the way!
I am using this simple code to populate the DB
tx.executeSql('CREATE TABLE IF NOT EXISTS details (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, phone TEXT)');
But it is causing double entries.
Stopping this can be as easy as defining a two field primary key, like this :
This key will ensure no entry in the database has the same name and phone.
Hope this helps !