Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6582185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:14:56+00:00 2026-05-25T16:14:56+00:00

I have a little problem with getting the elements in my sqlite database in

  • 0

I have a little problem with getting the elements in my sqlite database in android.My database looks like this :

id  /   serverName  /  objectId  /  objectOid  /  ....//objectId is actually userId-which I need to compare

I’m receiving an data from the server and I need to check the id of user from the server and local user id from the database.I have this piece of code :

public static Integer lUserIdByServerUserId(int serverUserId, String serverName){
    return localUserIdByServerUserId( serverUserId,  serverName);

}

private static Integer localUserIdByServerUserId(int serverUserId, String serverName){
    DataBaseHelper dbHelper = new DataBaseHelper(context, "ops_sys_tpl.sqlite",null,1);
    String query = "SELECT id FROM users WHERE objectId = "+serverUserId+" AND serverName = '"+serverName+"' LIMIT 1";
    ArrayList<String> result = new ArrayList<String>();
    cursor = dbHelper.executeSQLQuery(query);
    cursor.moveToFirst();
    while(!cursor.isAfterLast()) {
        result.add(cursor.getString(cursor.getColumnIndex("objectId")));
        cursor.moveToNext();
    }

    Log.i("result ","Result : "+result.toString());
    Log.i("CURSOR ","Cursor Position : "+cursor.getPosition());
    Integer uuid = Integer.parseInt(result.get(cursor.getColumnIndex("objectId")));
    Log.w("localUSerByIdServerUserId","LocalUserByIdServerUserId result : "+uuid);
    cursor.close();
    return uuid;
}

I am trying to check all the entries in database and if there is a match return it.I’m calling this method like this :

            uuId = rpc.lUserIdByServerUserId(userId,newServerName);

and i get this exception at this line : Integer uuid = Integer.parseInt(result.get(cursor.getColumnIndex("objectId")));

  09-20 16:55:47.647: WARN/System.err(31031): java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
09-20 16:55:47.647: WARN/System.err(31031):     at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
09-20 16:55:47.647: WARN/System.err(31031):     at java.util.ArrayList.get(ArrayList.java:311)
09-20 16:55:47.647: WARN/System.err(31031):     at com.stampii.stampii.comm.rpc.RPCCommunicator.localUserIdByServerUserId(RPCCommunicator.java:1083)
09-20 16:55:47.647: WARN/System.err(31031):     at com.stampii.stampii.comm.rpc.RPCCommunicator.lUserIdByServerUserId(RPCCommunicator.java:1066)
09-20 16:55:47.657: WARN/System.err(31031):     at com.stampii.stampii.comm.rpc.InfoStartRPCPacket.executeBefore(InfoStartRPCPacket.java:176)
09-20 16:55:47.657: WARN/System.err(31031):     at com.stampii.stampii.user.UserLogin$2$1.run(UserLogin.java:212)
09-20 16:55:47.657: WARN/System.err(31031):     at java.lang.Thread.run(Thread.java:1102)
09-20 16:55:47.657: WARN/ERROR(31031):  Error  - java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0

And actually I have only one test entry in my database which is the same as the userID return from server.

Any ideas where is my mistake and how to fix that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:14:56+00:00Added an answer on May 25, 2026 at 4:14 pm

    Problem was due to cursor’s position

    Try this code for position the cursor to start point.

     if (mNotesCursor.moveToFirst()) {
          do {
             result.add(cursor.getString(cursor.getColumnIndex("objectId")));
          } while (mNotesCursor.moveToNext());
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little problem with getting all data from SQLite database and showing
Hey most of my issue has been solved but i have little problem This
having a little problem getting the information from my spinner, this is how i
Hey all, i'm having a little problem with ksoap2 and getting response i have
have a little problem with this code: UITableViewCell *cell = (UITableViewCell *)[[button superview] superview];
i have little problem with boost::asio library. My app receive and process data asynchronously,
I have a little problem with a Listview. I can load it with listview
I have a little Java problem I want to translate to Python. Therefor I
I've run on a little problem today: I have a JS drop down menu
I have a little demonstration below of a peculiar problem. using System; using System.Windows.Forms;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.