3

Possible Duplicate:
Get updated rows count from SQLite in Android using a raw query?

I want to get the number of rows affected by a sqlite insert command. My query looks something link this:

String sql = "INSERT OR REPLACE INTO "+TABLE_USER+" (`...
                ")" ;

        c = myDataBase.rawQuery(sql, null);

My research was not successful. I found something like a count() command for sql but I didn't get it to work. How do I get the number of modified rows of a sql INSERT command?

serv-inc
  • 35,772
  • 9
  • 166
  • 188
user1324936
  • 2,187
  • 4
  • 36
  • 49

1 Answers1

0

You should try with the changes() function to return the number of affected rows.

"The changes() function returns the number of database rows that were changed or inserted or deleted by the most recently completed INSERT, DELETE, or UPDATE statement, exclusive of statements in lower-level triggers. The changes() SQL function is a wrapper around the sqlite3_changes() C/C++ function and hence follows the same rules for counting changes." -- "http://www.sqlite.org"

secretlm
  • 2,361
  • 2
  • 27
  • 38