Hi,
You don't need to pass anything.
Try to use myDB.insert instead of myDB.execSQL, for instance:
ContentValues values = new ContentValues();
values.put(field1, value_for_field1);
values.put(field2, value_for_field2);
myDB.insert(MY_TABLE, null, values);
Realize that you do not need to inform what is the value for your PK field.
After calling myDB.insert you will get, as return, the PK value used to
create your record.
You also can find more detailed information on
http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#insert(java.lang.String,
java.lang.String, android.content.ContentValues)
Éderson
On Mon, Dec 7, 2009 at 12:11 PM, Jags jag...@gmail.com wrote:
i am doing sqlite3
my tables's pk is auto-increment. What shpuld i pass its value while
inserting so that auto increment executes properly ?
public void writeRecord(Row rec) {
try {
Object[] bindArgs = new Object[] {-1, rec.name, rec.email};
myDB.execSQL(INSERT INTO
+ MY_TABLE
+ VALUES (?, ?, ?);, bindArgs);
}
catch(Exception e) {
Log.d(Exception: , e.getMessage());
}
}
moreover, i need to extract this newly generated pk value, how can i
get that ?
regards
--
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en