-
Notifications
You must be signed in to change notification settings - Fork 25
Locally Stored Models
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 "";
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 "";
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
Sponsored by DSpot Sp. z o.o. Contact us at info@dspot.com.pl