java - What in this method is leading to 'force close'? -


I need to remove a row from the database table, and then further changes over the long run, the following lines.

  public void updateDraftsAfterDelete (long rowId) {string txt = "", rid = "", STO = "" is = "" sin = ""; Boolean B = true; Cursor = db.query (DATABASE_DRAFTS_TABLE, new String [] {KEY_DRAFTS_ROWID, KEY_DRAFTS_SENDTO, KEY_DRAFTS_TXT, KEY_DRAFTS_ENCST, KEY_DRAFTS_SIN}, null, null, null null, null); Cursor.moveToPosition ((int) (rowId +1)); Material values ​​= new material value (); For (int i = (int) rowId; I & LT; cursor.getCount (); i ++) {rid = new String ( "" + ((Integer.parseInt (cursor.getString (0))) - 1 )); STO = cursor.getString (1); Txt = cursor.getString (2); Est = cursor.getString (3); Sin = cursor.getString (4); Values.put (KEY_DRAFTS_SENDTO, STO); Values.put (KEY_DRAFTS_TXT, txt); Values.put (KEY_DRAFTS_ENCST, A); Values.put (KEY_DRAFTS_SIN, sin); B = db.update (DATABASE_DRAFTS_TABLE, values, + KEY_DRAFTS_ROWID "=" + rid zero) & gt; 0; Cursor.moveToNext (); } Cursor.moveToLast (); Rid = cursor.getString (0); Toast. Make Text (empty, get rid, toast. Langtha_long). Show (); B = db.delete (DATABASE_DRAFTS_TABLE, KEY_DRAFTS_ROWID + "=" + rid, zero)> 0; }   

upon running it, it is not removing the last line when the lines are transferred properly What is the problem? Thank you.

If you need to pass a reference object to call to Toast.makeText , You can not pass the null, it will force an NullPointerException to throw and close

change the line

  Toast.makeText (zero, rid, toast.LENGTH_LONG) .show () .;   

to:

  context reference = getApplicationContext (); Toast. Make text (context, liberation, toast. Langtha_long). Show ();    

Comments