مشکل در دیتابس اندروید
زمانیکه من یک آیتم راحذف میکنم app من کراش کرده و cursor من indexoutofbounds میدهد لطفا کمک کنید
public void refresh()
{
handler.open();
int counterTemp = 0;
for (int k = 0; k < handler.countTime(); k++)
{
if (CustomAdapter_For_WatchDay.dateOfWatchDay.equalsIgnoreCase(handler.displayTime(k, 8)))
counterTemp++;
}
num = new int[counterTemp];
counterTemp = 0;
for (int j = 0; j < handler.countTime(); j++)
{
if (CustomAdapter_For_WatchDay.dateOfWatchDay.equalsIgnoreCase(handler.displayTime(j, 8)) &&
counterTemp < num.length)
{
num[counterTemp] = Integer.parseInt(handler.displayTime(j, 1));
counterTemp++;
}
}
Arrays.sort(num);
int counter = 0;
for (int i = 0; i < 25; i++)
{
if (counter < num.length && i == num[counter])
{
listHours(handler.customDisplayTime(num[counter], CustomAdapter_For_WatchDay.dateOfWatchDay, 0));
counter++;
}
else if (i < 4) {
list.add(new Time_Contact( (i) + "-" + (i + 1) + " بامداد ", "----", "----",
"----", "----", "----","----"));
}
else if (i >= 4 && i < 10){
list.add(new Time_Contact( (i) + "-" + (i + 1) + " صبح ", "----", "----",
"----", "----", "----","----"));
}
else if (i >= 10 && i < 13)
{
list.add(new Time_Contact( (i) + "-" + (i + 1) + " ق.ظ ", "----", "----",
"----", "----", "----","----"));
}
else if (i >= 13 && i < 19){
list.add(new Time_Contact( ((i - 12)) + "-" + ((i - 12) + 1) + " ب.ظ ", "----", "----",
"----", "----", "----","----"));
}
else if (i >= 19 && i < 24)
{
list.add(new Time_Contact( ((i - 12)) + "-" + ((i - 12) + 1) + " شب ", "----", "----",
"----", "----", "----","----"));
}
}
handler.close();
}

پاسخ ها ( 1 )
سلام
خطای index out of bounds معوملا در آرایه ها رخ میده و علتش هم اینه که مثلا آرایه ای دارید با 5 عضو، ولی مقدار بیشتری رو به آرایه ارسال میکنید(مثلا مقدار 6) و چون وجود نداره، همچین خطایی میده
بررسی کنید کدتون رو دوباره …
index out of bounds از cursor است و میدانم چرا فقط شما اگر راه حلی دارید که پیشنهاد کنید برای ما تشکر میکنم