I am trying to update the database to show that something has been uploaded. At the end of the method where I have uploaded the information I have the following code to change a column value from 0 to 1 where 1 means that something has been uploaded but I am getting an error.
Here is what my code looks like:
ContentValues cv = new ContentValues();
cv.put(ProviderMetaData.TableMetaData.HAS_UPLOADED, "1");
String where = ProviderMetaData.TableMetaData._ID + "=" + contenturi;
String[] value = {"0"};
ContentResolver cr = this.mContext.getContentResolver();
cr.update(ProviderMetaData.TableMetaData.CONTENT_URI, cv, where, value);
and the error message I am getting is as follows:
Error upldating hasupladed=1 using UPDATE tablename SET hasuploaded=? WHERE _id=1
Does anyone see the error here or know what I am doing wrong?
I am not sure of what is the value of the variable
contenturi, but you do not need it there. If I am not wrong the correct code you need is either:Or even:
Depending on whether you want the id set dynamically or not.
The main difference between my code and yours is that I use the where arguments as they are meant to be used – in the where caluse you place question marks on the places where their values are to be inserted and then Android
SQLiteDatabasesubstitutes their values accordingly.