Reputation: 942
I have a basic database that calls on string into the database(well supposed to). Whenever I click the button to save the string into the data base I get an error in my log cat saying it did not write to the data base. the application keeps going but no info shows inside the database.
LOGCAT
12-02 16:39:03.551: E/Database(20828): 0.0
12-02 16:39:03.551: E/Database(20828): 0.0
12-02 16:39:03.551: E/Database(20828): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed
12-02 16:39:03.551: E/Database(20828): at android.database.sqlite.SQLiteStatement.native_execute(Native Method)
12-02 16:39:03.551: E/Database(20828): at android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:61)
12-02 16:39:03.551: E/Database(20828): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1591)
12-02 16:39:03.551: E/Database(20828): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1435)
12-02 16:39:03.551: E/Database(20828): at http.www.hotapp.com.timeandlocation.db.Database.createEntryLat(Database.java:76)
12-02 16:39:03.551: E/Database(20828): at http.www.hotapp.com.timeandlocation.TimeAndLocationActivity.onClick(TimeAndLocationActivity.java:131)
12-02 16:39:03.551: E/Database(20828): at android.view.View.performClick(View.java:2485)
12-02 16:39:03.551: E/Database(20828): at android.view.View$PerformClick.run(View.java:9089)
12-02 16:39:03.551: E/Database(20828): at android.os.Handler.handleCallback(Handler.java:587)
12-02 16:39:03.551: E/Database(20828): at android.os.Handler.dispatchMessage(Handler.java:92)
12-02 16:39:03.551: E/Database(20828): at android.os.Looper.loop(Looper.java:123)
12-02 16:39:03.551: E/Database(20828): at android.app.ActivityThread.main(ActivityThread.java:3806)
12-02 16:39:03.551: E/Database(20828): at java.lang.reflect.Method.invokeNative(Native Method)
12-02 16:39:03.551: E/Database(20828): at java.lang.reflect.Method.invoke(Method.java:507)
12-02 16:39:03.551: E/Database(20828): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-02 16:39:03.551: E/Database(20828): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-02 16:39:03.551: E/Database(20828): at dalvik.system.NativeStart.main(Native Method)
ENTRY METHOD
public long createEntryLat(String slat) {
// TODO Auto-generated method stub
ContentValues cv = new ContentValues();
cv.put(KEY_LATITUDE, slat);
return ourdb.insert(DATABASE_TABLE, null, cv);
}
LINE 73
return ourdb.insert(DATABASE_TABLE, null, cv);
ONCLICK METHOUD
case R.id.button001:
lat = (EditText)findViewById(R.id.textLat);
String slat = lat.getText().toString();
//String slon = lon.getText().toString();
Database entries = new Database (this);
entries.open();
entries.createEntryLat(slat);
entries.close();
break;
LINE 131
Database entries = new Database (this);
I have no idea what I am doing wrong and would love any help thanks.
Upvotes: 0
Views: 285
Reputation: 942
I had to uninstall my application then re-install it for my changes to take action.
Upvotes: 1
Reputation: 1380
The topmost line in the stack says:
12-02 16:39:03.551: E/Database(20828): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed
Is there a constraint you are violating:
Can you post the create sql for the table in question?
Upvotes: 4