Refresh all columns in an ormlite database table in Android

I have the following database table object:

public class Goal {
    @DatabaseField(generatedId = true)
    private int id;
    @DatabaseField
    private String goal_title;
    @DatabaseField
    private String goal_desc;
    @DatabaseField
    private String goal_why;
    ...
}

I have added several rows to this table, and now I want to write a query to update all the columns of a row in this table. I saw the ORM documentation and couldn't figure out how to write this query. Please help me how to write this request.

+5
source share
1 answer

I think you need RTFM. I read ORMLite for a long time , and I think it covers pretty wellUpdateBuilder . Feel free to ask more specific questions, and I can add more details if not.

For quoting from documents:

DAO UPDATE DELETE. , WHERE, , no where(). Delete , WHERE, , ().

Goal:

UpdateBuilder<Goal, Integer> updateBuilder = goalDao.updateBuilder();
// update the goal_title and goal_why fields
updateBuilder.updateColumnValue("goal_title", "some other title");
updateBuilder.updateColumnValue("goal_why", "some other why");
// but only update the rows where the description is some value
updateBuilder.where().eq("goal_desc", "unknown description");
// actually perform the update
updateBuilder.update();

, .

+17

All Articles