Android ORM framework ActiveAndroid and ormactiveandroid
1. In AndroidManifest. xml, we need to add these two
AA_DB_NAME (Database name, which cannot be changed, but is optional. If this parameter is left blank, the default value is "Application. db)
AA_DB_VERSION (the database version number is also optional-the default value is 1)
<Manifest...>
<Application android: name = "com. activeandroid. app. Application"...>
...
<Meta-data android: name = "AA_DB_NAME" android: value = "Pickrand. db"/>
<Meta-data android: name = "AA_DB_VERSION" android: value = "5"/>
</Application>
</Manifest>
2. initialize In the first Activity or application
3. To create an object class, you must inherit from the Model. Use @ Table (name = "table_name") to indicate the Table bound to the object class, and use @ Column (name = "Category ") id field name
For example:
@ Table (name = "table_name ")
Public class Category extends Model {
@ Column (name = "Name ")
Public String name;
}
4. Operations
Model class comes with save () call to save
Select class included in the Framework
For example, new Select (). form (Category. class). execute () is a chained programming. You can view it on your own.
The built-in delete instance of the Framework is no longer provided. You can view it by yourself.
5. Database Upgrade
Change the database version AA_DB_VERSION in AndroidManifest. xml
Create an SQL file and directory structure (/migrations/version number after upgrade. SQL) in the assest directory. You need to write the SQL statement for changing the database (one SQL statement in one line) in the file)
Corresponding field added to the Category object
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.