I'm new in android development and am getting this errors when click my "getir" button. It error after work. How to solve this issue
my code code:
public void getir(View view)
{
cursor = myData.rawQuery("SELECT * FROM kolonVeri", null);
int gunIx = cursor.getColumnIndex("gun");
int vtarihIx = cursor.getColumnIndex("vTarih");
cursor.moveToFirst();
while (cursor != null)
{
System.out.println("VARDİYA: " + cursor.getString(gunIx));
System.out.println("TARİH: " + cursor.getString(vtarihIx));
cursor.moveToNext();
}
}
error log
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.hakannacar.vardiyam, PID: 19541
java.lang.IllegalStateException: Could not execute method for android:onClick
om.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.reflect.InvocationTargetException
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.database.CursorIndexOutOfBoundsException: Index 4 requested, with a size of 4