Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Locally Stored Models

Adrián Rivero edited this page May 7, 2017 · 18 revisions

These models are annotated with @LocalDBModel, they will be automatically loaded and stored to SQLite database using ActiveAndroid ORM library.

They should extend from the class com.activeandroid.Model:

@LocalDBModels
public class MyModel extends Model {

}

Parameters:

Assign a name to the table to be used to store in SQLite... with the empty default value, the name is generated as the plural of the word used in lowercase.

String table() default "";

Default query to be used if not other query is provided to inject the model.

String defaultQuery() default "";

Parameters to the injection using @Model:

This value is used as the Where clause for the query in ActiveAndroid. A custom query can be done also starting the text with a "select" statement.

String query() default "";

This value is used as the orderBy clause for the query in ActiveAndroid

String orderBy() default "";

Specify a default query for all the injected models, when not query is provided

String defaultQuery() default "";

Configuring the Application to use ActiveAndroid:

To configure your application to use ActiveAndroid ORM and @LocalDBModel, it is enough to add to the Application class the annotation @UseLocalDB. The application class should be annotated with @EApplication as well.

@UseLocalDB
@EApplication
public class MyApplication extends Application {
}

It is mandatory to reference to the enhanced application object in your AndroidManifest.xml

<application
        android:name=".MyApplication_">

Example

See also