Skip to content
Advertisement

save text file in sqlite android

I want to save text file in sqlite android but it is giving an error android.database.sqlite.SQLiteConstraintException: NOT NULL constraint failed: at line long result = db.insert(TABLE_NAME,null,cv);.

JavaScript

The path gives this in log Download/Link_on.txt and the readFile(path) returns [49, 10, 48, 48, 58, 48…… but it is still failing to save the text file in db. Thanks for the help.

Advertisement

Answer

In the CREATE statement of the table you have defined the column POSITION as NOT NULL, but in the method add_txt_file() you don’t supply a value.

Add something like this line:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement