[Solved] Duplicate data issue android sqlite


You should have a SQLiteOpenHelper class which contains some methods for database management and lifecycle like

onCreate(SQLiteDatabase db) // Called when the database is created for the first time.
onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) //Called when the database needs to be downgraded.
onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) // Called when the database needs to be upgraded.

And other ones, you can have a look here: http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html

Following this tutorial should keep you on the good path about using this helper:
http://developer.android.com/training/basics/data-storage/databases.html

My advice is to create some Querys like the ones that will populate and execute them after the creation of the Tables which should be there too. This way, your app will only make those inserts the first time, and keep them even if you update your database (if you don’t state something else on the onUpgrade() method).

This should fix your problem.

1

solved Duplicate data issue android sqlite