0

I am a beginner in this field and I need help to finish a simple application (obviously not simple for me). My database looks like this: enter image description here

And my method in the DatabaseHelper is:

public void EditList(User user)
{
    db.execSQL( "UPDATE " + TABLE_USER + " SET " + DOLIST + "='" + user.getDoList() + "' WHERE " +  USERNAME + " LIKE "+"'"+user.getUsername()+"'");
}

I tried this but my app keeps crashing when I click the button that activates this method. Here is my project if somebody wants to take a look (18mb): https://drive.google.com/open?id=1_Mz1JLlWD2Lm2XoGNdj1lCFXbxRmEw2a Any help is appreciated.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
A. Newbie
  • 187
  • 1
  • 3
  • 17

1 Answers1

0

Try this. Maybe you forgot to assign write mode.

public void EditList(User user)
{

        db = this.getWritableDatabase();
        db.execSQL( "UPDATE " + TABLE_USER + " SET " + DOLIST + "='" + user.getDoList() + "' WHERE " +  USERNAME + " LIKE "+"'"+user.getUsername()+"'");

}
phonemyatt
  • 1,287
  • 17
  • 35
  • Thank you mate. Can you answer me one more question if you have time? I have this LoginEditText.setText(chislo); code where chislo is type int and LoginEditText is android:inputType="number" , is there any chance I can pass the integer to this edit text? – A. Newbie Nov 18 '17 at 23:28
  • Do you want to set your LoginEditText limit only to number? or show only numbers keypad? One way is to set your LoginEditText digit to numbers "android:digits="0123456789" in your layout xml and set listener like this "LoginEditText.setKeyListener(DigitsKeyListener.getInstance("0123456789");" – phonemyatt Nov 19 '17 at 04:04
  • Refer to this post. might help you answer your question. [post](https://stackoverflow.com/questions/6919360/how-do-i-restrict-my-edittext-input-to-numerical-possibly-decimal-and-signed-i) – phonemyatt Nov 19 '17 at 04:05
  • That's very helpful for future apps. I passed the integer like this LoginEditText.setText(Integer.toString(chislo)); and I have other checks for the input in this LoginEditText. Thank you for the help again :) – A. Newbie Nov 19 '17 at 15:18