0
我下面https://github.com/pardom/ActiveAndroid/wiki/Querying-the-database納入activeandroid在我的應用程序,像這樣:ActiveAndroid NPE從執行
@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數據庫?
發佈堆棧跟蹤並顯示你要調用的地方'ActiveAndroid.initialize()' – laalto 2014-09-19 04:51:44
就是它了;添加此作爲答案,我會將其標記爲已接受 – 2014-09-19 18:48:10