Android: Search data and Update data
<p>I'm a student and new to android programming and Sqlite. I've been working with my project which is the android Quiz. My only problem is on how to update the data. Before the user can update the data he/she will first search the ID of the data and the data will be loaded to the EditText. Then when I click the Button Update their is nothing change with my data. There is no error in the logcat.Please check my code. Help me Please Thank you so much..</p>

<p><strong>My DatabaseHelper class:</strong></p>

<pre><code>public void updateData(int id, String new_question, String new_ans1, String new_ans2, String new_ans3, String new_ans4, SQLiteDatabase sqLiteDatabase )
    {
        ContentValues contentValues = new ContentValues();

        contentValues.put(AdminContact.Question.COLUMN_QUESTION, new_question);
        contentValues.put(AdminContact.Question.COLUMN_ANSWER1, new_ans1);
        contentValues.put(AdminContact.Question.COLUMN_ANSWER2, new_ans2);
        contentValues.put(AdminContact.Question.COLUMN_ANSWER3, new_ans3);
        contentValues.put(AdminContact.Question.COLUMN_ANSWER4, new_ans4);


        sqLiteDatabase.update(AdminContact.Question.TABLE_QUIZ, contentValues, AdminContact.Question.ID +"="+id, null);


    }
</code></pre>

<p><strong>My Update Class:</strong></p>

<pre><code> EditText Search_Id, New_Question, New_Ans1, New_Ans2, New_Ans3, New_Ans4;
DatabaseHelper helper;
String SearchID, NewId, NewQuestion, NewAns1, NewAns2, NewAns3, NewAns4;
SQLiteDatabase sqLiteDatabase;
TextView title_text;
Button updateButton;
int id;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_update_contact);
    helper = new DatabaseHelper(this);

    Search_Id = (EditText) findViewById(R.id.id_search);
    New_Question = (EditText) findViewById(R.id.new_question);
    New_Ans1 = (EditText) findViewById(R.id.new_ans1);
    New_Ans2 = (EditText) findViewById(R.id.new_ans2);
    New_Ans3 = (EditText) findViewById(R.id.new_ans3);
    New_Ans4 = (EditText) findViewById(R.id.new_ans4);
    title_text = (TextView) findViewById(R.id.title_text);
    updateButton = (Button) findViewById(R.id.update_button);
    New_Question.setVisibility(View.GONE);
    New_Ans4.setVisibility(View.GONE);
    New_Ans3.setVisibility(View.GONE);
    New_Ans2.setVisibility(View.GONE);
    New_Ans1.setVisibility(View.GONE);
    title_text.setVisibility(View.GONE);
    updateButton.setVisibility(View.GONE);


}

public void searchContact(View view) {

    SearchID = Search_Id.getText().toString();
    sqLiteDatabase = helper.getReadableDatabase();
    Cursor cursor = helper.getData(SearchID, sqLiteDatabase);
    if (cursor.moveToFirst()) {
        NewQuestion = cursor.getString(0);
        NewAns1 = cursor.getString(1);
        NewAns2 = cursor.getString(2);
        NewAns3 = cursor.getString(3);
        NewAns4 = cursor.getString(4);
        NewId = SearchID;

        New_Question.setText(NewQuestion);
        New_Ans1.setText(NewAns1);
        New_Ans2.setText(NewAns2);
        New_Ans3.setText(NewAns3);
        New_Ans4.setText(NewAns4);
        New_Ans4.setVisibility(View.VISIBLE);
        New_Ans3.setVisibility(View.VISIBLE);
        New_Ans2.setVisibility(View.VISIBLE);
        New_Ans1.setVisibility(View.VISIBLE);
        New_Question.setVisibility(View.VISIBLE);
        title_text.setVisibility(View.VISIBLE);
        updateButton.setVisibility(View.VISIBLE);

    }

}


public void updateData(View view)
{
    sqLiteDatabase = helper.getWritableDatabase();
    String question, ans1, ans2, ans3, ans4;

    question = New_Question.getText().toString();
    ans1 = New_Ans1.getText().toString();
    ans2 = New_Ans2.getText().toString();
    ans3 = New_Ans3.getText().toString();
    ans4 = New_Ans4.getText().toString();

    helper.updateData(id,question,ans1,ans2,ans3,ans4,sqLiteDatabase);
    Toast.makeText(getApplicationContext(),"Successfully Updated", Toast.LENGTH_LONG).show();

}
</code></pre>