????ActiveAndroid?????????????ORM??????????????????????????????????????????д?????????SQL???
????ActiveAndroid git???
????????
????1??AndroidManifeset??????????????
<application
...
android:name="com.activeandroid.app.Application"
>
<meta-data
android:name="AA_DB_NAME"
android:value="xxx.db" />
<meta-data
android:name="AA_DB_VERSION"
android:value="7" />
<meta-data
android:name="AA_MODELS"
android:value="com.syd.oden.odendemo.entity.sqltab.LocationTab?? com.syd.oden.odendemo.entity.sqltab.MusicFavorTab" />
????AA_MODELS???????б???????
????2??Application???com.activeandroid.app.Application
????public class MyApplication extends com.activeandroid.app.Application {}
????????
public class MyApplication extends SomeLibraryApplication {
@Override
public void onCreate() {
super.onCreate();
ActiveAndroid.initialize(this);
}
@Override
public void onTerminate() {
super.onTerminate();
ActiveAndroid.dispose();
}
}
????3????????
@Table(name = "PictureTabs")
public class PictureTab extends Model {
private static MyLog myLog = new MyLog("[PictureTab] ");
@Column(name = "dirName")
String dirName;
@Column(name = "fileName")
String fileName;
@Column(name = "describe")
String describe;
@Column(name = "longitude")
double longitude;
@Column(name = "latitude")
double latitude;
public PictureTab() {
super();
}
public PictureTab(String dirName?? String fileName?? double longitude?? double latitude) {
super();
this.dirName = dirName;
this.fileName = fileName;
this.longitude = longitude;
this.latitude = latitude;
}
}
??????????
??????
for (int i=0; i<5; i++) {
DbBlesGroup dbBleGroup = new DbBlesGroup();
dbBleGroup.groupIndex = i;
dbBleGroup.groupName = "groupName" + i;
dbBleGroup.addr = "addr" + i;
dbBleGroup.name = "name" + i;
dbBleGroup.save();
}
??????
???????????
List<DbBlesGroup> dbBleGroupList = new ArrayList<>();
dbBleGroupList = new Select()
.from(DbBlesGroup.class)
.orderBy("groupName ASC")
.execute();
for (int i=0; i<dbBleGroupList.size(); i++)
{
L.d("dbBleGroupList :" + dbBleGroupList.get(i).groupName);
}
???????????????
List<DbBlesGroup> dbBleGroupList = new ArrayList<>();
dbBleGroupList = new Select()
.from(DbBlesGroup.class)
.where("groupName = ?"?? "groupName3")
.orderBy("groupName ASC")
.execute();
??????????????
????newSelect().from(UserViewTab.class).where("viewId=? and bleAddr=?"??viewId??addr).executeSingle();
???????????(transaction)
ActiveAndroid.beginTransaction();
try {
for (int i = 0; i < 100; i++) {
Item item = new Item();
item.name = "Example " + i;
item.save();
}
ActiveAndroid.setTransactionSuccessful();
}
finally {
ActiveAndroid.endTransaction();
}
.orderBy(“id DESC”)????
.orderBy(“id ASC”)????
???????
????new Delete().from(DbBlesGroup.class).where("groupName = ?"?? "groupName2").execute();
??????
????new Update(DbBlesGroup.class).set("addr = ?"?? "123").where("groupName = ?"?? "groupName2").execute();
????????????save???
???????????
????1?????????м?ü???super();
????2????sudio2.2???б???????
????erro?? 'java.lang.String com.activeandroid.TableInfo.getTableName()' on a null object reference.
???????Instant Run

????3?????а?????????????????????????????????
???????????bug?????а??????????????????????????????????
????recipeAlarmList.add(RecipeAlarmTab.getById(recipeTab.getRecipeAlarmTab1().getId())); //activeAndroidò????bug???????ID???2?????