【发布时间】:2016-12-09 08:21:10
【问题描述】:
我学习在我的 Android 应用中使用 ActiveAndroid,谁能告诉我如何只保存具有唯一 ID 的数据?在我的模型中,我将 id 设置为非主键列。这是我的模型类:
package com.project.echo.contactmanagement.data;
import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;
import com.activeandroid.query.Select;
import com.google.gson.annotations.Expose;
import java.util.List;
@Table(name="Contacts" , id = "idColumn")
public class Post extends Model {
@Expose
@Column(name = "ProfilePic")
public String profilePic;
@Expose
@Column(name = "id")
public Integer id;
@Expose
@Column(name = "FirstName")
public String firstName;
@Expose
@Column(name = "LastName")
public String lastName;
public Post()
{
super();
}
public Post(String profilePic, Integer id, String firstName, String lastName)
{
this.profilePic=profilePic;
this.id=id;
this.firstName=firstName;
this.lastName=lastName;
}
public String getProfilePic() {
return profilePic;
}
/*public Integer getId() {
return id;
}*/
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public static List selectAll() {
return new Select().from(Post.class).execute();
}
}
感谢您的帮助
【问题讨论】:
标签: android activeandroid