0

I have this table in my SQLDatabase:

CREATE TABLE Book(_id INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT NOT NULL)

Now my problem is that with this code no exception is thrown:

ContentValues args = new ContentValues();           
args.put("Name", "");

long id = db.insertOrThrow("Book", null, args);

I want that an exception is thrown if I try to put an empty string into the Name column. In the LogCat there is no exception too. What do I have to change in the table?

1 Answer 1

1

An empty string is different from NULL, instead of throw an exception for empty strings, do a simple test and then execute whatever you would have in your catch block.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.