Summary of use of Android:greendao and parcelable

Source: Internet
Author: User
Tags sqlite database

Greendao The storage of object data can be implemented with parcelable.

1. Greendao

Greendao is an ORM solution that can help Android developers quickly map Java objects to a form in a SQLite database, and by using a simple object-oriented API, developers can store, update, delete, and query Java objects.

2. parcelable

parcelable is an interface used in Android for serializing and deserializing object data.

Note: Greendao automatically generated info can inherit the Parcelable interface, enabling serialization and deserialization of data storage.

    • Cases:

public class contractdeatilinfo implements parcelable{    /**  not-null value. */    private string id;     private string name;    private string party_a;     private string party_b;    public contractdeatilinfo ()  {     }    public contractdeatilinfo (String id)  {         this.id = id;    }     Public contractdeatilinfo (string id, string name, string party_a, string  party_b, string sign_date, string value, string remarks)  {         this.id = id;         this.name = name;        this.party_a = party_a;         this.party_b = party_b;    }    /**  Not-null value. */    public string getid ()  {         return id;    }    /**  not-null value; ensure this value is available before it is  Saved to the database. */    public void setid (String  ID)  {        this.id = id;    }     public string getname ()  {         return name;    }    public void setname (String  name) &NBSP;{&NBSP;&NBSP;&NBSP;&NBsp;    this.name = name;    }    public  string getparty_a ()  {        return party_a;     }    public void setparty_a (String party_a)  {         this.party_a = party_a;    }     public string getparty_b ()  {         return party_b;    }    public void setparty_b ( String party_b)  {        this.party_b = party_b;     }     //  above is Greendao automatically generated info, the following is the implementation of Parcelable interface content   @Overridepublic  int describecontents ()  {return 0;} Implement serialization, J@overridepublic void writetoparcel (parcel d est, int flags)  {dest.writestring (ID);d est.writestring (name);d est.writestring (party_a); Dest.writestring (party_b);} Implement deserialization, parse out from parcel public static final parcelable.creator<contractdeatilinfo>  Creator = new creator<contractdeatilinfo> ()  {@Overridepublic  contractdeatilinfo [] newarray (Int size)  {return new contractdeatilinfo[size];} @Overridepublic  contractdeatilinfo createfromparcel (Parcel source)  {contractdeatilinfo  info = new contractdeatilinfo (); info.id = source.readstring (); info.name =  source.readstring (); info.party_a = source.readstring ();info.party_b =  Source.readstring (); return info;}};}


Summary of use of Android:greendao and parcelable

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.