What isn't this code inserting values into SQLite database?

前端 未结 3 771
时光取名叫无心
时光取名叫无心 2021-01-26 10:16

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

相关标签:
3条回答
  • 2021-01-26 10:57

    instead of db.insert() ... use db.insertOrThrow(), probably some constraint error.

    0 讨论(0)
  • 2021-01-26 11:06

    Try to place this.db.insert(TABLE_CONTACTS, null, values);. Because I had the same problem few months ago and that is the solution.

    0 讨论(0)
  • 2021-01-26 11:14

    What is your db object? Is it SQLiteDatabase db = this.getWriteableDatabase(); ? I have seen that some people uses getReadAbleDatabase() istead of the getWriteableDatabase() method.

    0 讨论(0)
提交回复
热议问题