Reputation: 2052
I am trying to update a DATETIME column in a Sqlite table using the following query.
String query = "UPDATE myTable SET displayed = datetime('now') where _id = " + id;
database.rawQuery(query, null);
I have tested this on both device and emulator but its not working, its not updating the value in the column.
PS: I tried the same query in Sqlite browser and its working there.
Please help me figure out a solution.
Thanks.
Upvotes: 1
Views: 6879
Reputation: 4707
Instead of using rawQuery()
, use execSQL()
if the execution doesn't return any data.
String query = "UPDATE myTable SET displayed = datetime('now') where _id = " + id;
database.execSQL(query);
Though just a tip, it is better to use UNIX time if you really want to store and process date in the future. It will be more flexible and standardized.
Upvotes: 3