Android ORM framework ActiveAndroid and ormactiveandroid

Source: Internet
Author: User

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.

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.