PreviousArticleOrmlite is simple to use, but I think ormlite is superior to the configuration design for fields, tables, and so on.
The following describes the class Configuration:
If the Android app we developed needs to retain user information, create a new class: useraccount
This class has six variables:
Private IntID;
PrivateString username;
PrivateString password;
PrivateDate regtime;
PrivateString tellphone;
PrivateString email;
Use eclipse to generate get and set methods:
Public Int GETID (){
Return ID;
}
Public Void Setid ( Int ID ){
This . ID = ID;
}
Public String GetUserName (){
Return Username;
}
Public Void Setusername (string username ){
This . Username = username;
}
Public String GetPassword (){
Return Password;
}
Public Void Setpassword (string password ){
This . Password = password;
}
Public Date getregtime (){
Return Regtime;
}
Public Void Setregtime (date regtime ){
This . Regtime = regtime;
}
Public String gettellphone (){
Return Tellphone;
}
Public Void Settellphone (string tellphone ){
This . Tellphone = tellphone;
}
Public String getemail (){
Return Email;
}
Public Void Setemail (string email ){
This . Email = Email;
}
The persistence parameters of the class are configured as follows:
1. Table Name:
@ Databasetable (tablename = "datatablename ")
If this parameter is not specified, the table name is the class name.
2. Fields
@ Databasefield
This can be configured with a lot of attributes.
2.1 primary key
@ Databasefield (ID = true)
2.2 column name
@ Databasefield (columnname = "columnname ")
If this parameter is not specified, it is the same as the variable name.
2.3 Data Type
@ Databasefield (datatype = datatype. integer)
In general, you do not need to specify this parameter. You can obtain this parameter based on the Java class.
2.4 Default Value
@ Databasefield (defaultvalue = "0 ")
2.5 Length
@ Databasefield (width = 13)
It is generally used for string type
2.6 empty
@ Databasefield (canbenull = false)
The default value is true.
2.7 self-growth?
@ Databasefield (generatedid = true)
This is relatively simple. Let's talk about the foreign key in the next article.