Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to update selected column in the SQLite database - Android
    primarykey
    data
    text
    <p>I need to updated selected columns in my database, however i am unable to get the updated data.As soon as the user click on next button, the data should get updated.There are total 12 fields that needs to be updated in the table.</p> <p>Note: dba is DBAdapter i.e the database and myDB is SQLiteDatabase</p> <pre><code> nxt = (Button)findViewById(R.id.btn_nxt); nxt.setOnClickListener(new OnClickListener(){ public void onClick(View v) { String b1=t1.getText().toString(); String b2=goal_website_trying_to_achieve_edttxt.getText().toString(); String b3=communicate_edttxt.getText().toString(); String b4=success_look_like_edttxt.getText().toString(); String b5=usp_insights_edttxt.getText().toString(); String b6=act_edttxt.getText().toString(); String b7=market_edttxt.getText().toString(); String b8=your_current_website_www_edttxt.getText().toString(); String b9=your_current_website_good_edttxt.getText().toString(); String b10=your_current_website_bad_edttxt.getText().toString(); String b11=your_current_website_type_edttxt.getText().toString(); String b12=your_current_website_update_edttxt.getText().toString(); String b13=your_current_website_supporting_edttxt.getText().toString(); if(!validatescreen2()){ return; } else{ dba.open(); String updatequery = "UPDATE "+ DBAdapter.DATABASE_TABLE+ " SET "; updatequery = updatequery + " KEY_MESSAGE_1 = " + b1 +"WHERE" +"_id"+mRowId +","; updatequery = updatequery + " KEY_MESSAGE_2 = " + b2 +"WHERE" +"_id"+mRowId + ","; updatequery = updatequery + " KEY_MESSAGE_3 = " + b3 +"WHERE" +"_id"+mRowId + ","; updatequery = updatequery + " KEY_MESSAGE_4 = " + b4 +"WHERE" +"_id"+mRowId + ","; updatequery = updatequery + " KEY_MESSAGE_5 = " + b5 +"WHERE" +"_id"+mRowId + ","; updatequery = updatequery + " KEY_MESSAGE_6 = " + b6 + "WHERE" +"_id"+mRowId +"',"; updatequery = updatequery + " KEY_YOUR_CURRENT_WEBSITE_1 = " + b7 + "WHERE" +"_id"+mRowId +","; updatequery = updatequery + " KEY_YOUR_CURRENT_WEBSITE_2 = " + b8 +"WHERE" +"_id"+mRowId + ","; updatequery = updatequery + " KEY_YOUR_CURRENT_WEBSITE_3 = " + b9 +"WHERE" +"_id"+mRowId + ","; updatequery = updatequery + " KEY_YOUR_CURRENT_WEBSITE_TYPE = " + b10 + "WHERE" +"_id"+mRowId +","; updatequery = updatequery + " KEY_YOUR_CURRENT_WEBSITE_NEED = " + b11 + "WHERE" +"_id"+mRowId +","; updatequery = updatequery + " KEY_YOUR_CURRENT_WEBSITE_OTHER = " + b12 + "WHERE" +"_id"+mRowId ; try{ myDB.execSQL(updatequery); }catch(Exception e){ Log("Caught while writing response" + e.getLocalizedMessage()); }finally{ if(myDB != null)myDB.close(); } showDialog(DIALOG_ID); dba.close(); } } }); </code></pre> <p>changes made</p> <pre><code>String updatequery = "UPDATE"+ DBAdapter.DATABASE_TABLE+ " SET "+ DBAdapter.KEY_MESSAGE_1 +"= "+ b1 + DBAdapter.KEY_MESSAGE_2 +"= "+ b2 + DBAdapter.KEY_MESSAGE_3 +"= "+ b3 + DBAdapter.KEY_MESSAGE_4 +"= "+ b4 + DBAdapter.KEY_MESSAGE_5 +"= "+ b5 + DBAdapter.KEY_MESSAGE_6 +"= "+ b6+ DBAdapter.KEY_YOUR_CURRENT_WEBSITE_1 +"= "+ b7 + DBAdapter.KEY_YOUR_CURRENT_WEBSITE_2 +"= "+ b8 + DBAdapter.KEY_YOUR_CURRENT_WEBSITE_3 +"= "+ b9+ DBAdapter.KEY_YOUR_CURRENT_WEBSITE_TYPE +"= "+ b10 + DBAdapter.KEY_YOUR_CURRENT_WEBSITE_NEED +"= "+ b11 + DBAdapter.KEY_YOUR_CURRENT_WEBSITE_OTHER +"= " + b12 + "WHERE" + DBAdapter.KEY_ROWID + "=" + mRowId ; logcat error file 01-30 12:02:24.136: W/System.err(2645): java.lang.NullPointerException 01-30 12:02:24.136: W/System.err(2645): at com.example.sales.Newform_Screen2$3.onClick(Newform_Screen2.java:165) 01-30 12:02:24.136: W/System.err(2645): at android.view.View.performClick(View.java:4084) 01-30 12:02:24.136: W/System.err(2645): at android.view.View$PerformClick.run(View.java:16966) 01-30 12:02:24.136: W/System.err(2645): at android.os.Handler.handleCallback(Handler.java:615) 01-30 12:02:24.136: W/System.err(2645): at android.os.Handler.dispatchMessage(Handler.java:92) 01-30 12:02:24.136: W/System.err(2645): at android.os.Looper.loop(Looper.java:137) 01-30 12:02:24.136: W/System.err(2645): at android.app.ActivityThread.main(ActivityThread.java:4745) 01-30 12:02:24.136: W/System.err(2645): at java.lang.reflect.Method.invokeNative(Native Method) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload