2016-09-05 5 views
-1

は私のジェイソン・レスポンスであり、あなたが反応して見ることができるように、このために私はSugarOrmAndroid SUGAR ORMを使用してSQlite DBにカスタムクラスobjを保存しますか?以下

{ 
    "id": "300", 
    "location": "59", 
    "location_name": "new bel road ", 
    "cushy_lat": "13.03135560", 
    "cushy_lng": "77.57323110", 
    "tags": "[Baba, Nimit]", 
    "description": "Nimit baba", 
    "emoticon": "3", 
    "lat": "13.02891950", 
    "lng": "77.57151030", 
    "media_url": "http:\/\/dev.cushy.com\/useruploads\/196821e0c5de0b28b96048d556fc3934.JPEG", 
    "user": { 
     "id": "1", 
     "fullname": "Joseph Ranjan", 
     "email": "[email protected]", 
     "total_cushy": "7", 
     "followers_count": "1", 
     "following_count": "1", 
     "am_i_following": 1, 
     "is_he_following": 0, 
     "user_dp": "http:\/\/cushy.com\/userdp\/89aefdba9be455761b8992d8f813328e.jpeg" 
    }, 
    "distance": "0.49", 
    "cushy_time": "yesterday", 
    "last_navigation": "yesterday", 
    "is_liked": 0, 
    "is_navigated": 0, 
    "is_wishlist": 0 
} 

私のメインモデルクラス

@SerializedName("ids") 
private String CUSHYID; 
@SerializedName("location") 
private String location; 
@SerializedName("location_name") 
private String location_name; 
@SerializedName("cushy_lat") 
private String cushy_lat; 
@SerializedName("cushy_lng") 
private String cushy_lng; 
@SerializedName("tags") 
private ArrayList<String> tags; 
@SerializedName("description") 
private String description; 
@SerializedName("emoticon") 
private String emoticon; 
@SerializedName("lat") 
private String lat; 
@SerializedName("lng") 
private String lng; 
@SerializedName("media_url") 
private String media_url; 

@SerializedName("user") 
private Users user; 

@SerializedName("distance") 
private String distance; 
@SerializedName("cushy_time") 
private String cushy_time; 
@SerializedName("last_navigation") 
private String last_navigation; 
@SerializedName("is_liked") 
private String is_liked; 
@SerializedName("is_navigated") 
private String is_navigated; 
@SerializedName("is_wishlist") 
private String is_wishlist; 

public CUSHYRECORD() { 
} 

public String getCUSHYID() { 
    return CUSHYID; 
} 

public void setCUSHYID(String CUSHYID) { 
    this.CUSHYID = CUSHYID; 
} 

public String getLocation() { 
    return location; 
} 

public void setLocation(String location) { 
    this.location = location; 
} 

public String getLocation_name() { 
    return location_name; 
} 

public void setLocation_name(String location_name) { 
    this.location_name = location_name; 
} 

public String getCushy_lat() { 
    return cushy_lat; 
} 

public void setCushy_lat(String cushy_lat) { 
    this.cushy_lat = cushy_lat; 
} 

public String getCushy_lng() { 
    return cushy_lng; 
} 

public void setCushy_lng(String cushy_lng) { 
    this.cushy_lng = cushy_lng; 
} 

public ArrayList<String> getTags() { 
    return tags; 
} 

public void setTags(ArrayList<String> tags) { 
    this.tags = tags; 
} 

public String getDescription() { 
    return description; 
} 

public void setDescription(String description) { 
    this.description = description; 
} 

public String getEmoticon() { 
    return emoticon; 
} 

public void setEmoticon(String emoticon) { 
    this.emoticon = emoticon; 
} 

public String getLat() { 
    return lat; 
} 

public void setLat(String lat) { 
    this.lat = lat; 
} 

public String getLng() { 
    return lng; 
} 

public void setLng(String lng) { 
    this.lng = lng; 
} 

public String getMedia_url() { 
    return media_url; 
} 

public void setMedia_url(String media_url) { 
    this.media_url = media_url; 
} 

public Users getUser() { 
    return user; 
} 

public void setUser(Users user) { 
    this.user = user; 
} 

public String getDistance() { 
    return distance; 
} 

public void setDistance(String distance) { 
    this.distance = distance; 
} 

public String getCushy_time() { 
    return cushy_time; 
} 

public void setCushy_time(String cushy_time) { 
    this.cushy_time = cushy_time; 
} 

public String getLast_navigation() { 
    return last_navigation; 
} 

public void setLast_navigation(String last_navigation) { 
    this.last_navigation = last_navigation; 
} 

public String getIs_liked() { 
    return is_liked; 
} 

public void setIs_liked(String is_liked) { 
    this.is_liked = is_liked; 
} 

public String getIs_navigated() { 
    return is_navigated; 
} 

public void setIs_navigated(String is_navigated) { 
    this.is_navigated = is_navigated; 
} 

public String getIs_wishlist() { 
    return is_wishlist; 
} 

public void setIs_wishlist(String is_wishlist) { 
    this.is_wishlist = is_wishlist; 
} 

を拡張する2つのモデルクラスを持っている」と呼ばれる1以上の内側のオブジェクトがありますユーザー"。だから私は同じ

public class Users extends SugarRecord{ 

public Users(){ 

} 

private String cushyid; 
@SerializedName("ids") 
private String userid; 
@SerializedName("fullname") 
private String fullname; 
@SerializedName("email") 
private String email; 
@SerializedName("total_cushy") 
private String total_cushy; 
@SerializedName("followers_count") 
private String followers_count; 

@SerializedName("following_count") 
private String following_count; 
@SerializedName("am_i_following") 
private String am_i_following; 
@SerializedName("is_he_following") 
private String is_he_following; 
@SerializedName("user_dp") 
private String user_dp; 

public String getCushyid() { 
    return cushyid; 
} 

public void setCushyid(String cushyid) { 
    this.cushyid = cushyid; 
} 

public String getUserid() { 
    return userid; 
} 

public void setUserid(String userid) { 
    this.userid = userid; 
} 

public String getFullname() { 
    return fullname; 
} 

public void setFullname(String fullname) { 
    this.fullname = fullname; 
} 

public String getEmail() { 
    return email; 
} 

public void setEmail(String email) { 
    this.email = email; 
} 

public String getTotal_cushy() { 
    return total_cushy; 
} 

public void setTotal_cushy(String total_cushy) { 
    this.total_cushy = total_cushy; 
} 

public String getFollowers_count() { 
    return followers_count; 
} 

public void setFollowers_count(String followers_count) { 
    this.followers_count = followers_count; 
} 

public String getFollowing_count() { 
    return following_count; 
} 

public void setFollowing_count(String following_count) { 
    this.following_count = following_count; 
} 

public String getAm_i_following() { 
    return am_i_following; 
} 

public void setAm_i_following(String am_i_following) { 
    this.am_i_following = am_i_following; 
} 

public String getIs_he_following() { 
    return is_he_following; 
} 

public void setIs_he_following(String is_he_following) { 
    this.is_he_following = is_he_following; 
} 

public String getUser_dp() { 
    return user_dp; 
} 

public void setUser_dp(String user_dp) { 
    this.user_dp = user_dp; 
} 

}

のための別のモデルクラスを作成今、このUserクラスは、値がDBに格納取得されていないので、カスタムクラスがあります。私のcoulmnは作成されていますが、これに価値はありません。誰も私にこの問題を解決する方法を提案してください。事前に

おかげ..

答えて

0

読むhttp://satyan.github.io/sugar/

あなたがユーザーのためのデフォルトコンストラクタがあります。

public Users(){ 
} 

をしかし、あなたはNO実際のコンストラクタを持っている(ので、何のデータベースが作成されません):

public Users(){ 
String cushyid, 
String userid, 
String fullname, 
String email, 
String total_cushy, 
String followers_count, 
String following_count, 
String am_i_following, 
String is_he_following, 
String user_dp){ 
this.cushyid = cushyid; 
... 
    } 
関連する問題