The error could be causing because of the following reasons.
There is a bug in the addItem function of the blog. When you insert an item in the local database it actually does assign an id to it. When you call the insert function on the table it returns an object with an id.
So insert for todoItem should look like this.
final ToDoItem entity = mToDoTable.insert(item).get();
The correct version of the addItem function looks like this
public void addItem(View view) {
if (mClient == null) {
return;
}
// Create a new item
final ToDoItem item = new ToDoItem();
item.setText(mTextNewToDo.getText().toString());
item.setComplete(false);
// Insert the new item
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
final ToDoItem entity = mToDoTable.insert(item).get();
if (!entity.isComplete()) {
runOnUiThread(new Runnable() {
public void run() {
mAdapter.add(entity);
}
});
}
} catch (Exception exception) {
createAndShowDialog(exception, "Error");
}
return null;
}
}.execute();
mTextNewToDo.setText("");
}
- There is a bug Android SDK (https://github.com/Azure/azure-mobile-services/issues/505). According to which your Mobile Service and the client table definitions should match. When you create the todoItem table it adds the "__deleted" column by default. You can either define the column in your client or remove it from todoItem table.