Back to project page android-mvc-framework.
The source code is released under:
Apache License
If you think the Android project android-mvc-framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.android_mvc.sample_project.db.entity; //from w w w. j a v a 2 s . c o m import android.content.ContentValues; import android.database.Cursor; import com.android_mvc.sample_project.db.entity.lib.LogicalEntity; /** * ???????????????????????? * @author id:language_and_engineering * */ public class Friend extends LogicalEntity<Friend> { // Intent????????????????????????????????????? private static final long serialVersionUID = 1L; // ??????? public String tableName(){return "friends";} // ??? public final String[] columns(){ return new String[]{ "id", "name", "age", "favorite_flag" }; } // ???? private Long id = null; private String name = null; private Integer age = null; private Boolean favorite_flag = null; // IDE??????????????G&S public Long getId() { return id; } public String getName() { return name; } public Integer getAge() { return age; } public void setId(Long id) { this.id = id; } public void setName(String name) { this.name = name; } public void setAge(Integer age) { this.age = age; } public Boolean getFavorite_flag() { return favorite_flag; } public void setFavorite_flag(Boolean favoriteFlag) { favorite_flag = favoriteFlag; } // ??????? /** * ???????????????????????? */ public String getDescription() { String friend_description = "id:" // ?for?????????????????????????StringBuilder??? + getId() +"," + getName() + "????(" + getAge() +")" ; // ????????????????????????? if( getFavorite_flag() ) { friend_description += "?"; } return friend_description; } // ----- LP????(Logical <-> Physical) ----- /** * DB????????????????????? */ @Override public Friend logicalFromPhysical(Cursor c) { setId(c.getLong(0)); setName(c.getString(1)); setAge( c.getInt(2) ); setFavorite_flag( c.getInt(3) == 1 ); return this; } /** * ???DB???????????????????????????????????? */ @Override protected ContentValues toPhysicalEntity(ContentValues values) { // entity?ContentValue??????? if( getId() != null) { values.put("id", getId()); } values.put("name", getName()); values.put("age", getAge()); values.put("favorite_flag", getFavorite_flag() ? 1 : 0); return values; } }