Sample Item list Application that uses SQLite and ActiveAndroid
The application uses CRUD operations.
The operations: C and R (Create and Read) & D (Delete)
To use ActiveAndroid you will need to go to your project level build.gradle file and add the following to the allprojects
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
Dependency Used
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
Add this meta-data to your AndroidManifest.xml
<meta-data android:name="AA_DB_NAME" android:value="MyDatabase.db" />
<meta-data android:name="AA_DB_VERSION" android:value="5" />
Create a class named MyApplication to initialize the ActiveAndroid library
public class MyApplication extends Application {
/*
Initialized ActiveAndroid Library
*/
@Override
public void onCreate() {
super.onCreate();
//Initializing Active Android
ActiveAndroid.initialize(this);
}
}
Then you will need to define your class in your AndroidManifest.xml file
<application
android:name=".MyApplication"
Next you will create a model for the table
//This is the Items table name
@Table(name = "Items")
public class Items extends Model {
//The table consist only one field name
@Column(name = "name")
public String name;
}
Once the table model as been created you will need to define your models inside the AndroidManifest.xml file.
<meta-data
android:name="AA_MODELS"
android:value="packagename.TableName" />
<meta-data
android:name="AA_MODELS"
android:value="androidproject.com.androidsqliteactiveandroid.Items" />