Reputation: 559
Trying to insert data in database from edittext in android but data is not inserting.
MY CODE --
ContentValues values= new ContentValues();
values.put(KEY_EMAIL, GlobalVar.email);
values.put(KEY_NAME, GlobalVar.name);
myDataBase.insert(MY_EMP, null,values);
MY LOG CAT
04-10 09:50:20.121: E/running(280): create database called
04-10 09:50:20.121: E/running(280): chek database called
04-10 09:50:20.121: E/running(280): chek database try block called
04-10 09:50:20.171: E/running(280): create database called try block
04-10 09:50:20.191: E/running(280): copy database called
04-10 09:50:20.211: E/running(280): open data successfull
04-10 09:50:50.720: W/KeyCharacterMap(280): No keyboard for id 0
04-10 09:50:50.720: W/KeyCharacterMap(280): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
`
Upvotes: 0
Views: 2318
Reputation: 2047
If you don't supply all the required column data (i.e. data for all columns that don't have a default value, accept null, or are auto-incrementing), then the insert command will fail.
However, if insert
fails, it doesn't throw an exception. It just returns -1.
Check the result of your insert
call, or better yet, change the call to
myDataBase.insertOrThrow(MY_EMP, null,values);
and then check the logs for the exception message assuming there is one.
Upvotes: 2
Reputation: 1199
It seems u r missing the required parameters in myDataBase.insert(MY_EMP, null,values); it should be myDataBase.insert("Table Name ", "First column name ",cv);
Try this
Upvotes: 1