Question

I want check cursor's row value. If cursor's row value is null I set "" my array's value, if cursor's row value not null i set "1" my array's value. How can i check my cursor's value ?

Cursor okunanlar = v3.GetAllRows();
okunanlar.moveToLast();
for(int i=0;i<10;i++)
{
   if("How can i check my cursor's row value in here")
  {
      kayitlar[i]="";
  }
   else
  {
       kayitlar[i]="1";                         
  }
  okunanlar.moveToPrevious();
}

Solve problem!

Cursor okunanlar = v3.GetAllRows();
                if (okunanlar.getCount() > 0) {
                    okunanlar.moveToLast();
                    for (int i = 0; i < (okunanlar.getCount()%10); i++) {
                        if (okunanlar.isNull(okunanlar.getColumnIndexOrThrow("name"))) {
                            kayitlar[i] = "";
                            okunanlar.moveToPrevious();
                        } else {
                            kayitlar[i] = okunanlar.getString(okunanlar
                                    .getColumnIndex("name"));
                            okunanlar.moveToPrevious();
                        }
                    }
                    veriAdaptoru = new ArrayAdapter<String>(TabBar.this,
                            android.R.layout.simple_expandable_list_item_1,
                            android.R.id.text1, kayitlar);
                    Tab3.liste.setAdapter(veriAdaptoru);
                }
            }
Was it helpful?

Solution

Assuming that you want to check ONE field in your row you can use the following:

if(cursor.isNull(cursor.getColumnIndexOrThrow("column_index") || cursor.getString(cursor.getColumnIndexOrThrow("column_index")).equals("")) to check if it is null or empty.

Where "column_index" is the name of the column in your database

Edit: If what you want is the ROW position just use cursor.getPosition() to get the row position in your cursor.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top