开发者

Cursor going out of bound

开发者 https://www.devze.com 2023-03-10 15:15 出处:网络
I have a scenerio in which i have to move the cursor to next and previous. I am runing into exception when the cursor is already at the first or last location, then it throws out of bound exception.

I have a scenerio in which i have to move the cursor to next and previous. I am runing into exception when the cursor is already at the first or last location, then it throws out of bound exception.

How to tackle this situation ? What is the best way to handle it and currently i am handling it with exception [try and catch].

 public boolean nextWord()
   {
 boolean isVald = false;
 try
 {
    i开发者_运维问答sVald = currentCursor.moveToNext();
    fillCurrentWord();

 } catch (Exception e)
 {
    Log.e("nextWord", e.toString());
 }

 return isVald;
  }


if (!currentCursor.isLast()){
    currentCursor.moveToNext();
    // ...
}


You can verify your current position using one of the following methods: isFirst(), isBeforeFirst(), isLast() or isAfterLast()

0

精彩评论

暂无评论...
验证码 换一张
取 消