I have imported the latest version of android Sugar ORM library into eclipse and have referenced it from my project. To the manifest i have added the following meta tags:
<meta-data
android:name="DATABASE"
android:value="venn_app.db" />
<meta-data
android:name="VERSION"
android:value="7" />
<meta-data
android:name="QUERY_LOG"
android:value="true" />
This is my POJO object:
public class Event extends SugarRecord<Event> {
int id;
LatLng latLng = new LatLng(0,0);
String name;
Long startTime = new Long(0);
boolean isSelected = false;
boolean isCheckedIn = false;
public Event(){ }
public Event(int id, String name, LatLng latLng){
startTime = System.currentTimeMillis(); // divide by 1000 to get seconds
this.id = id;
this.latLng = latLng;
this.name = name;
isSelected = false;
isCheckedIn = false;
}
This Call always results with null pointer exception even though the object is not null. Do i need to instantiate the Database?
try {
Event event = new Event(0, name, lat, longi);
Log.d("sugar", event.toString());
event.save();
} catch (Exception e) {
Log.d("sugar", "failed to add an event");
Log.d("sugar", e.toString());
}
I am using Nexus 7.
I was missing:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:name="com.orm.SugarApp" >
android:name="com.orm.SugarApp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With