I use Java annotations to achieve the Android SQLite Orm Library, previously written XML, but the feeling is not very stable, efficiency, robustness of all aspects are not very good, today spent an afternoon of time, complete all the annotations, comments, generated Javadoc, wrote a sample program, and posted on GitHub, the address is: Https://github.com/Steven-Luo/AnnotationDao, interested can try to use, than the previous purely manual implementation of SQLite database operation is much simpler, scalability is also good, Use the following:
1 //entity class2@Table (name = "Dog")3 Public classDog {4 Private BooleanAlive;5 Private intID;6 PrivateString name;7 8 PublicDog () {9 Ten } One A PublicDog (BooleanAlive, String name) { - This. Alive =Alive; - This. Name =name; the } - -@Id (name = "Id") -@Column (name = "id", type =Datatype.integer) + Public intgetId () { - returnID; + } A at@Column (name = "Name", type = datatype.varchar, length = 20) - PublicString GetName () { - returnname; - } - -@Column (name = "Alive", type =Datatype.boolean) in Public BooleanisAlive () { - returnAlive; to } + - Public voidSetalive (Booleanalive) { the This. Alive =Alive; * } $ Panax Notoginseng Public voidSetId (intID) { - This. ID =ID; the } + A Public voidsetName (String name) { the This. Name =name; + } - } $ $ //Add -Annotationdao DAO =NewAnnotationdao ( This, Dog.class); - theString name = "Dog1"; - BooleanAlive =true;Wuyi theDog dog =NewDog (alive, name); - Dao.insert (dog); Wu - //Find About //List all Objects $List List =dao.list (); - //Query by ID -Dao.query (3); - A //Delete + Dao.delete (dog); the - //Update, you need to ensure that the ID field corresponds to the value in the database, that is, the previous call to list or query to take out the $Dog.setname ("Dog2"); theDao.update (dog);
These days to do a project, which need to draw some curves, although achartengine has been very useful, but there are a few pictures feel not quite agreeable, finally decided to draw a. In fact, mainly because of reading read the above reading time curve, I think the painting is good, so I also innovation a bit, or a cottage a bit, haha, the effect as shown:
Wait a day to write the comments, also put on GitHub up, good things, we want to share ^_^