I am writing an app for android. I need to read a txt file and write the data in an SQLite file. I have managed to complete all the code, but the part where it should insert the
instead of db.insert() ... use db.insertOrThrow(), probably some constraint error.
Try to place this.db.insert(TABLE_CONTACTS, null, values);
. Because I had the same problem few months ago and that is the solution.
What is your db
object? Is it SQLiteDatabase db = this.getWriteableDatabase();
? I have seen that some people uses getReadAbleDatabase()
istead of the getWriteableDatabase()
method.