2012-03-20 6 views
0

いくつかのレコードを含むデータベースがありますが、各行で実行したいコードがありますが、適切なループを作成するのに問題がありますが、(movetonext)ワーキング。私は必要があるだろう何データベースレコードを使用したコードのループ

cursor = getAppts(); 

cursor.moveToNext(); 

String titlefromdb = cursor.getString(3); 

if (strTitle.equals(titlefromdb) && cursor.getString(1).equals(dateselforap)) 
{ 
    // matching code update box 

    final Dialog matchdiag = new Dialog(CW2Organisor.this); 
    matchdiag.setContentView(R.layout.apptmatch); 
    matchdiag.setTitle("View/Edit Appointment"); 
    matchdiag.setCancelable(true); 

    TextView matchtxt = (TextView) matchdiag.findViewById(R.id.matchtxt); 

    matchtxt.setText("Appointment \"" + titlefromdb + "\" already exists, please choose a different event title"); 

    Button btnmatchok = (Button) matchdiag.findViewById(R.id.btnmatch); 
    btnmatchok.setOnClickListener(new OnClickListener() { 

     // on click for cancel button 

     @Override 
     public void onClick(View v) { 
      matchdiag.dismiss(); 
     } 
    }); 

    matchdiag.show(); 
} 
else 
{ 
addAppt(strTime, strTitle, strDet); 
dialog.dismiss(); 
} 

は、私は現在の行のタイトルフィールドを保持し、if文を実行し、次の行に移動するためtitlefromdbを必要とする私のデータベースの行ごとにあります。

+0

コードをフォーマットしてください。 –

答えて

0

あなたは

cursor.moveToFirst(); 

loop with some sort of check 
    cursor.moveToNext(); 
end loop 

を試みることができる...と私はまた、あなたの「それは働いていない」の文を修飾しようとするだろう。何がうまくいかないの?

+0

データベースから私はbeleive outofbounds例外を取得していました。 – nexus490

関連する問題