Search code examples
androidactiveandroid

ActiveAndroid Update and Delete from table


Hi guys so I'm trying to test how to use databases in android as part of one of my classes, but I'm pretty new to both so most help I found online has gone a bit over my head.

I was wondering how exactly do I update, and delete from the table. Currently I have:

    wk item = new wk();
            item.name = "okay1";
            item.save();

And that adds an item fine.

and in my database it has

public class wk extends Model {
    Table(name = "ToDoItems")
    @Column(name = "Name")

But I try to run

new Delete().from(wk.class).where("Name = ?",2).execute();

Which I'm assuming deletes the value at 2 in the database of Name, but instead it seems to do nothing? I have tried

new Delete().from(wk.class).execute();

Which does definitely delete my table so I know it can delete, but I just want to delete one value.

Pretty much I want to be able to delete that okay1 value.


Solution

  • Okay I found the answer I had for deleting which is

    new Delete().from(wk.class).where("Name = ?","okay1").execute();
    

    And works perfect for me now.