I just tried to use ActiveAndroid. Following their tutorial from here, I set everything. I added the manifest entry:
application android:name="com.activeandroid.app.Application" ...
meta-data android:name="AA_DB_NAME" android:value="MyDb.db" meta-data android:name="AA_DB_VERSION" android:value="1"
and created my model class:
package com.mycomp.Model;
import org.joda.time.LocalDate;
import org.odata4j.core.Guid;
import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;
@Table(name = "Table1")
public class Table1 extends Model
{
@Column(name = "Custom_ID")
public Guid Custom_ID;
@Column(name = "Name")
public String Name;
@Column(name = "Usr_type")
public int Usr_type;
@Column(name = "BDate")
public LocalDate BDate;
public MyEnum UserGroup;
public Table1()
{
super();
}
public Table1(String name, LocalDate date, Guid custom_id,
MyEnum userGroup)
{
super();
Name = name;
BDate = date;
Custom_ID = custom_id;
UserGroup = userGroup;
}
}
After that, I used the save method (it allegedly creates the underlying database structure):
Table1 t1=new Table1();
t1.Name="Test";
t1.UserGroup = MyEnum.G1;
t1.save();
It threw an exception: table Table1 has no column named Name
I checked it with SQLite Browser. The table exists but contains only one field: Id. What else should I do to create the other fields?
There is another solution: change the AA_DB_VERSION metadata value and place the modification scripts to the assets/migrations folder so ActiveAndroid will use the upgrade function. It comes handy when there are already data in the database.
Source: https://github.com/pardom/ActiveAndroid/wiki/Schema-migrations