Canot Retrieve items of arraylist which filled by Database in android?
<p>I am working on the project related to quiz contest. In project i want two event on same button click, like when user click on button(Answer option) it retrive him to another question(from same array list) and on the same time the clicked answer get saved into database.
Thanks in advance !</p>

<p>I am doing something like this..</p>

<pre><code>public class QuizeActivity extends Activity implements
        android.view.View.OnClickListener {
    private List&lt;String&gt; Questionlist = new ArrayList&lt;String&gt;();
    private List&lt;String&gt; FirstOptionlist = new ArrayList&lt;String&gt;();
    private List&lt;String&gt; SecondOptionlist = new ArrayList&lt;String&gt;();
    private List&lt;String&gt; ThirdOptionlist = new ArrayList&lt;String&gt;();
    private List&lt;String&gt; FourthOtionlist = new ArrayList&lt;String&gt;();
    private List&lt;String&gt; RightOtionlist = new ArrayList&lt;String&gt;();
    DBAdapter db = new DBAdapter(this);
    private String question, opt_one, opt_two, opt_three, opt_four, roght;
    private Button op1_btn, op2_btn, op3_btn, op4_btn;
    private TextView quest;
    private int count = 0;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        quest = (TextView) findViewById(R.id.ques_txt);
        op1_btn = (Button) findViewById(R.id.optOne_btn);
        op2_btn = (Button) findViewById(R.id.optSec_btn);
        op3_btn = (Button) findViewById(R.id.optThrd_btn);
        op4_btn = (Button) findViewById(R.id.optFrt_btn);
        op1_btn.setOnClickListener(this);
        op2_btn.setOnClickListener(this);
        op3_btn.setOnClickListener(this);
        op4_btn.setOnClickListener(this);

        Questionlist.clear();
        FirstOptionlist.clear();
        SecondOptionlist.clear();
        ThirdOptionlist.clear();
        FourthOtionlist.clear();
        RightOtionlist.clear();

        // ---get all titles---
        try {
            db.open();
            Cursor c = db.getAllTitles();
            if (c.moveToFirst()) {
                do {
                    DisplayTitle(c);
                } while (c.moveToNext());
            }
            c.close();
            db.close();

        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        on_ButtonClick();

    }

    private void DisplayTitle(Cursor c) {
        // TODO Auto-generated method stub
        Questionlist.add(c.getString(1));
        FirstOptionlist.add(c.getString(2));
        SecondOptionlist.add(c.getString(3));
        ThirdOptionlist.add(c.getString(4));
        FourthOtionlist.add(c.getString(5));
        RightOtionlist.add(c.getString(6));
    }

    private void on_ButtonClick() {
                quest.setText(Questionlist.get(count));
                op1_btn.setText(FirstOptionlist.get(count));
                op2_btn.setText(SecondOptionlist.get(count));
                op3_btn.setText(ThirdOptionlist.get(count));
                op4_btn.setText(FourthOtionlist.get(count));

    }

    public void onClick(View v) {
        // TODO Auto-generated method stub
        if (v == op1_btn) {

        }

        if (v == op2_btn) {
            count++;
        }
        if (v == op3_btn) {
            count++;
        }
        if (v == op4_btn) {
            count++;
        }

    }

}
</code></pre>
