Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I update an android sqlite database column value to null using ContentValues?

For example, I want to do the following on a database update.

Is there a constant I can use instead of null, which won't compile if I use it like:

ContentValues args = new ContentValues(); args.put(KEY_RISK_AMOUNT, null); // what constant do I use instead of null? 
like image 456
steve Avatar asked Jun 04 '11 01:06

steve


People also ask

How does SQLite handle null values?

Syntax. Following is the basic syntax of using NULL while creating a table. SQLite> CREATE TABLE COMPANY( ID INT PRIMARY KEY NOT NULL, NAME TEXT NOT NULL, AGE INT NOT NULL, ADDRESS CHAR(50), SALARY REAL ); Here, NOT NULL signifies that the column should always accept an explicit value of the given data type.

What is ContentValues Android SQLite?

ContentValues is a maplike class that matches a value to a String key. It contains multiple overloaded put methods that enforce type safety. Here is a list of the put methods supported by ContentValues: void put(String key, Byte value) void put(String key, Integer value)

Which SQLite statement is used to update data into table?

SQLite UPDATE Query is used to modify the existing records in a table. You can use WHERE clause with UPDATE query to update selected rows, otherwise all the rows would be updated.


1 Answers

Use ContentValues.putNull(java.lang.String):

ContentValues args = new ContentValues(); args.putNull(KEY_RISK_AMOUNT); 
like image 52
skolima Avatar answered Oct 12 '22 03:10

skolima