我正在关注https://github.com/pardom/ActiveAndroid/wiki/Querying-the-database将activeandroid合并到我的应用程序中,如下所示:
@Table(name="Contact")
public class Contact extends Model implements Serializable, Comparable {
public Contact() {
super();
}
public Contact(String id, String n, String c, String p, String addr, String phone,
String fb, String twit, String yt) {
super();
candID = id;
name = n;
chamber = c;
party = p;
address = addr;
phoneNo = phone;
facebook = fb;
twitter = twit;
youtube = yt;
}
public static List<Contact> getCachedContactsByState(String stateAbbr) {
/*return new Select().from(Contact.class).where("state = ?",
stateAbbr).execute();*/
Select s = new Select();
From f = s.from(Contact.class);
f = f.where("state = ?", stateAbbr);
List<Contact> cachedContacts = f.execute();
return cachedContacts;
}
根据我的调试器,f.execute抛出空指针异常,f不为空。
只是确保,教程没有提到在使用activeandroid之前需要安装sqlite,并且它说activeandroid的意思是使用对象及其功能在sqlite上做CRUD,所以我假设我只需要按照教程创建和查询我的sqlite数据库?