android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0

Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Samebug tips

,
via Stack Overflow by KristianMedK

You have an empty cursor. Check your query if it is not expected, or handle empty cursor with if(cursor.getCount() > 0) ...

,
via Stack Overflow by Rejinderi

When you get a Cursor returned from the database you should do an moveToFirst(); before trying to get data from it.

Solutions on the web

via Stack Overflow by Igal
, 2 years ago
Index 0 requested, with a size of 0
via Stack Overflow by akubabas
, 2 years ago
Index 0 requested, with a size of 0
via Stack Overflow by Unknown author, 2 years ago
android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
at android.database.AbstractCursor.checkPosition(AbstractCursor.java:418)
at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
at android.database.AbstractWindowedCursor.getInt(AbstractWindowedCursor.java:68)
at cz.jenda.pidifrky.data.pojo.Card$$anonfun$create$1.apply(Card.scala:77)
at cz.jenda.pidifrky.data.pojo.Card$$anonfun$create$1.apply(Card.scala:76)
at scala.util.Try$.apply(Try.scala:192)
at cz.jenda.pidifrky.data.pojo.Card$.create(Card.scala:75)
at cz.jenda.pidifrky.data.CursorWrapper$$anonfun$mapToList$1$$anonfun$apply$1.apply(CursorWrapper.scala:22)
at cz.jenda.pidifrky.data.CursorWrapper$$anonfun$mapToList$1$$anonfun$apply$1.apply(CursorWrapper.scala:22)
at scala.collection.immutable.Stream$$anonfun$map$1.apply(Stream.scala:418)
at scala.collection.immutable.Stream$$anonfun$map$1.apply(Stream.scala:418)
at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1233)
at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1223)
at scala.collection.immutable.Stream.flatMap(Stream.scala:491)
at cz.jenda.pidifrky.data.CursorWrapper$$anonfun$mapToList$1.apply(CursorWrapper.scala:22)
at cz.jenda.pidifrky.data.CursorWrapper$$anonfun$mapToList$1.apply(CursorWrapper.scala:22)
at scala.util.Try$.apply(Try.scala:192)
at cz.jenda.pidifrky.data.CursorWrapper.mapToList(CursorWrapper.scala:21)
at cz.jenda.pidifrky.data.dao.CardsDao$$anonfun$getAll$1.apply(CardsDao.scala:27)
at cz.jenda.pidifrky.data.dao.CardsDao$$anonfun$getAll$1.apply(CardsDao.scala:27)
at scala.util.Success$$anonfun$map$1.apply(Try.scala:237)
at scala.util.Try$.apply(Try.scala:192)
at scala.util.Success.map(Try.scala:237)
at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:235)
at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:235)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
at scala.concurrent.forkjoin.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1361)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

Users with the same issue

Samebug visitor profile picture
Unknown user
Once, 1 year ago
2 times, 1 year ago
2 times, 1 year ago
Once, 1 year ago
Samebug visitor profile picture
Unknown user
Once, 1 year ago

Write tip

Know the solutions? Share your knowledge to help other developers to debug faster.