مشکل در دیتابس اندروید
زمانیکه من یک آیتم راحذف میکنم app من کراش کرده و cursor من indexoutofbounds میدهد لطفا کمک کنید
۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹ ۱۰ ۱۱ ۱۲ ۱۳ ۱۴ ۱۵ ۱۶ ۱۷ ۱۸ ۱۹ ۲۰ ۲۱ ۲۲ ۲۳ ۲۴ ۲۵ ۲۶ ۲۷ ۲۸ ۲۹ ۳۰ ۳۱ ۳۲ ۳۳ ۳۴ ۳۵ ۳۶ ۳۷ ۳۸ ۳۹ ۴۰ ۴۱ ۴۲ ۴۳ ۴۴ ۴۵ ۴۶ ۴۷ ۴۸ ۴۹ ۵۰ ۵۱ ۵۲ ۵۳ ۵۴ ۵۵ ۵۶ ۵۷ ۵۸ ۵۹ ۶۰ |
public void refresh() { handler.open(); int counterTemp = ۰; for (int k = ۰; k < handler.countTime(); k++) { if (CustomAdapter_For_WatchDay.dateOfWatchDay.equalsIgnoreCase(handler.displayTime(k, ۸))) counterTemp++; } num = new int[counterTemp]; counterTemp = ۰; for (int j = ۰; j < handler.countTime(); j++) { if (CustomAdapter_For_WatchDay.dateOfWatchDay.equalsIgnoreCase(handler.displayTime(j, ۸)) && counterTemp < num.length) { num[counterTemp] = Integer.parseInt(handler.displayTime(j, 1)); counterTemp++; } } Arrays.sort(num); int counter = ۰; for (int i = ۰; i < ۲۵; i++) { if (counter < num.length && i == num[counter]) { listHours(handler.customDisplayTime(num[counter], CustomAdapter_For_WatchDay.dateOfWatchDay, 0)); counter++; } else if (i < ۴) { list.add(new Time_Contact( (i) + "-" + (i + ۱) + " بامداد ", "----", "----", "----", "----", "----","----")); } else if (i >= ۴ && i < 10){ list.add(new Time_Contact( (i) + "-" + (i + 1) + " صبح ", "----", "----", "----", "----", "----","----")); } else if (i >= ۱۰ && i < 13) { list.add(new Time_Contact( (i) + "-" + (i + 1) + " ق.ظ ", "----", "----", "----", "----", "----","----")); } else if (i >= ۱۳ && i < 19){ list.add(new Time_Contact( ((i - 12)) + "-" + ((i - 12) + 1) + " ب.ظ ", "----", "----", "----", "----", "----","----")); } else if (i >= ۱۹ && i < 24) { list.add(new Time_Contact( ((i - 12)) + "-" + ((i - 12) + 1) + " شب ", "----", "----", "----", "----", "----","----")); } } handler.close(); } |
پاسخ ها ( 1 )
سلام
خطای index out of bounds معوملا در آرایه ها رخ میده و علتش هم اینه که مثلا آرایه ای دارید با ۵ عضو، ولی مقدار بیشتری رو به آرایه ارسال میکنید(مثلا مقدار ۶) و چون وجود نداره، همچین خطایی میده
بررسی کنید کدتون رو دوباره …
index out of bounds از cursor است و میدانم چرا فقط شما اگر راه حلی دارید که پیشنهاد کنید برای ما تشکر میکنم