Q:

Error inserting in database - empty fields

I have an activity with a lot of fields, when i click on a button, all the values are stored into an sqlite database. 
When all my fields are completed this work fine, but i also want it to work when fields are empty, since my goal is to save the state of the fields to complete them later. 
But when i try to do this, i'm having this issue :  
E/SQLiteDatabase( 1542): Error inserting
E/SQLiteDatabase( 1542): android.database.sqlite. SQLiteException: near "null": syntax error: , while compiling: INSERT INTO IN_MISSION(null) VALUES (NULL)
E/SQLiteDatabase( 1542):        at android.database.sqlite. SQLiteCompiledSql.native_compile(Native Method)
E/SQLiteDatabase( 1542):        at android.database.sqlite. SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:68)
E/SQLiteDatabase( 1542):        at android.database.sqlite. SQLiteProgram.compileSql(SQLiteProgram.java:143)
E/SQLiteDatabase( 1542):        at android.database.sqlite. SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java:361)
E/SQLiteDatabase( 1542):        at android.database.sqlite. SQLiteStatement.acquireAndLock(SQLiteStatement.java:260)
E/SQLiteDatabase( 1542):        at android.database.sqlite. SQLiteStatement.executeInsert(SQLiteStatement.java:112)
E/SQLiteDatabase( 1542):        at android.database.sqlite. SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1718)
E/SQLiteDatabase( 1542):        at android.database.sqlite. SQLiteDatabase.insert(SQLiteDatabase.java:1591)
E/SQLiteDatabase( 1542):        at com.soft2rent.unicarmobile. DbManagement.insert(DbManagement.java:49)
E/SQLiteDatabase( 1542):        at com.soft2rent.unicarmobile. SaisieMission.onOptionsItemSelected(SaisieMission.java:75)
E/SQLiteDatabase( 1542):        at android.app. Activity.onMenuItemSelected(Activity.java:2502)
E/SQLiteDatabase( 1542):        at android.support.v4.app. FragmentActivity.onMenuItemSelected(FragmentActivity.java:373)
E/SQLiteDatabase( 1542):        at android.support.v7.app. ActionBarActivity.superOnMenuItemSelected(ActionBarActivity.java:245)
E/SQLiteDatabase( 1542):        at android.support.v7.app. ActionBarActivityDelegateICS.onMenuItemSelected(ActionBarActivityDelegateICS.java:164)
E/SQLiteDatabase( 1542):        at android.support.v7.app. ActionBarActivity.onMenuItemSelected(ActionBarActivity.java:131)
E/SQLiteDatabase( 1542):        at android.support.v7.app. ActionBarActivityDelegateICS$WindowCallbackWrapper.onMenuItemSelected(ActionBarActivityDelegateICS.java:308)
E/SQLiteDatabase( 1542):        at com.android.internal.policy.impl. PhoneWindow.onMenuItemSelected(PhoneWindow.java:950)
E/SQLiteDatabase( 1542):        at com.android.internal.view.menu. MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
E/SQLiteDatabase( 1542):        at com.android.internal.view.menu. MenuItemImpl.invoke(MenuItemImpl.java:149)
E/SQLiteDatabase( 1542):        at com.android.internal.view.menu. MenuBuilder.performItemAction(MenuBuilder.java:874)
E/SQLiteDatabase( 1542):        at com.android.internal.view.menu. ActionMenuView.invokeItem(ActionMenuView.java:490)
E/SQLiteDatabase( 1542):        at com.android.internal.view.menu. ActionMenuItemView.onClick(ActionMenuItemView.java:108)
E/SQLiteDatabase( 1542):        at android.view. View.performClick(View.java:3511)
E/SQLiteDatabase( 1542):        at android.view. View$PerformClick.run(View.java:14105)
E/SQLiteDatabase( 1542):        at android.os. Handler.handleCallback(Handler.java:605)
E/SQLiteDatabase( 1542):        at android.os. Handler.dispatchMessage(Handler.java:92)
E/SQLiteDatabase( 1542):        at android.os. Looper.loop(Looper.java:137)
E/SQLiteDatabase( 1542):        at android.app. ActivityThread.main(ActivityThread.java:4424)
E/SQLiteDatabase( 1542):        at java.lang.reflect. Method.invokeNative(Native Method)
E/SQLiteDatabase( 1542):        at java.lang.reflect. Method.invoke(Method.java:511)
E/SQLiteDatabase( 1542):        at com.android.internal.os. ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/SQLiteDatabase( 1542):        at com.android.internal.os. ZygoteInit.main(ZygoteInit.java:551)
E/SQLiteDatabase( 1542):        at dalvik.system. NativeStart.main(Native Method)

And here is the code of my query :
public long insert(Mission mission) {
    ContentValues cv = new ContentValues();

    cv = mission.getAll();
    return db.insert("IN_MISSION", null, cv);
}

What i want is to be able to set a field to null when it's empty in the app ! 
Thank you for reading ! 

A:

You can use following to insert data....
ContentValues contentvalue = new ContentValues();
contentvalue.put(TaskDatabaseHelper. FRND_USERNAME,uname); // column name : data..
contentvalue.put(TaskDatabaseHelper. FRND_FNAME, fname);
contentvalue.put(TaskDatabaseHelper. FRND_LNAME, lname);
contentvalue.put(TaskDatabaseHelper. FRND_EMAIL, email);

sqlitedb.insert(TaskDatabaseHelper. FRIENDS_TABLE_NAME, null, contentvalue); // adding data...

if You have blank data then insert  "" (blank data) but make sure that your column accepts blank data and not declared "NOT NULL"...

