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

  • SEARCH
  • Home
  • 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 8875755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:03:18+00:00 2026-06-14T19:03:18+00:00

I am having a problem trying to get the user details after signing in.

  • 0

I am having a problem trying to get the user details after signing in. I dont know if the problem is from the Database itself or a problem with using the Cursor.

Here is the CODE

public void onCreate(SQLiteDatabase db) {
    Log.d("SQLite OnCreate", "Creating table");
    String CREATE_LOGIN_TABLE = "CREATE TABLE " + TABLE_LOGIN + "("

    + KEY_NAME + " VARCHAR (255), " + KEY_MAIL + " VARCHAR (255), "
            + KEY_PASSWORD + " VARCHAR (255), " + KEY_ID
            + " VARCHAR(255), " + "unique_id " + "VARCHAR (255), "
            + KEY_COURSE1 + " VARCHAR(255), " + KEY_COURSE2
            + " VARCHAR(255), " + KEY_COURSE3 + " VARCHAR(255), "
            + KEY_COURSE4 + " VARCHAR(255), " + KEY_COURSE5
            + " VARCHAR(255), " + KEY_COURSE6 + " VARCHAR(255) " +     ");";
    db.execSQL(CREATE_LOGIN_TABLE);
    Log.d("SQLite OnCreate", "table created");

}

public HashMap<String, String> getUserDetails() {
    HashMap<String, String> user = new HashMap<String, String>();
    String selectQuery = "SELECT  * FROM " + TABLE_LOGIN;

    SQLiteDatabase db = this.getReadableDatabase();
    Cursor cursor = db.rawQuery(selectQuery, null);
    // Move to first row
    cursor.moveToNext();
    if (cursor.getCount() > 0) {
        user.put("name", cursor.getString(1));
        user.put("password", cursor.getString(3));
        user.put("email", cursor.getString(2));
        user.put("regId", cursor.getString(4));
        user.put("unique_id", cursor.getString(5));
        user.put("course1", cursor.getString(6));
        user.put("course2", cursor.getString(7));
        user.put("course3", cursor.getString(8));
        user.put("course4", cursor.getString(9));
        user.put("course5", cursor.getString(10));
        user.put("course6", cursor.getString(11));
    }
    cursor.close();
    db.close();
    // return user
    return user;
}

And in the Activity:

DatabaseStudents dbo = new DatabaseStudents(getApplicationContext());
            HashMap<String, String> details = dbo.getUserDetails();
             course1 = Integer.parseInt(details.get("course1"));
             course2 = Integer.parseInt(details.get("course2"));
             course3 = Integer.parseInt(details.get("course3"));
             course4 = Integer.parseInt(details.get("course4"));
             course5 = Integer.parseInt(details.get("course5"));
             course6 = Integer.parseInt(details.get("course6"));

BUT the logcat shows an error saying:

11-23 22:49:28.051: E/AndroidRuntime(2059): FATAL EXCEPTION: main
11-23 22:49:28.051: E/AndroidRuntime(2059): java.lang.RuntimeException: Unable to start      activity ComponentInfo{guc.edu.iremote/guc.edu.iremote.Main}:     java.lang.IllegalStateException: Couldn't read row 0, col 11 from CursorWindow.  Make sure     the Cursor is initialized correctly before accessing data from it.
11-23 22:49:28.051: E/AndroidRuntime(2059):     at     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
11-23 22:49:28.051: E/AndroidRuntime(2059):     at     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
11-23 22:49:28.051: E/AndroidRuntime(2059):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
11-23 22:49:28.051: E/AndroidRuntime(2059):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
11-23 22:49:28.051: E/AndroidRuntime(2059):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-23 22:49:28.051: E/AndroidRuntime(2059):     at android.os.Looper.loop(Looper.java:137)
11-23 22:49:28.051: E/AndroidRuntime(2059):     at android.app.ActivityThread.main(ActivityThread.java:4745)
11-23 22:49:28.051: E/AndroidRuntime(2059):     at java.lang.reflect.Method.invokeNative(Native Method)
11-23 22:49:28.051: E/AndroidRuntime(2059):     at java.lang.reflect.Method.invoke(Method.java:511)
11-23 22:49:28.051: E/AndroidRuntime(2059):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-23 22:49:28.051: E/AndroidRuntime(2059):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-23 22:49:28.051: E/AndroidRuntime(2059):     at dalvik.system.NativeStart.main(Native Method)
11-23 22:49:28.051: E/AndroidRuntime(2059): Caused by: java.lang.IllegalStateException:     Couldn't read row 0, col 11 from CursorWindow.  Make sure the Cursor is initialized     correctly before accessing data from it.
11-23 22:49:28.051: E/AndroidRuntime(2059):     at android.database.CursorWindow.nativeGetString(Native Method)
11-23 22:49:28.051: E/AndroidRuntime(2059):     at android.database.CursorWindow.getString(CursorWindow.java:434)
11-23 22:49:28.051: E/AndroidRuntime(2059):     at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)
11-23 22:49:28.051: E/AndroidRuntime(2059):     at guc.edu.iremote.DatabaseStudents.getUserDetails(DatabaseStudents.java:117)
11-23 22:49:28.051: E/AndroidRuntime(2059):     at guc.edu.iremote.Main.onCreate(Main.java:87)
11-23 22:49:28.051: E/AndroidRuntime(2059):     at android.app.Activity.performCreate(Activity.java:5008)
11-23 22:49:28.051: E/AndroidRuntime(2059):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
11-23 22:49:28.051: E/AndroidRuntime(2059):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
11-23 22:49:28.051: E/AndroidRuntime(2059):     ... 11 more
  • 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-06-14T19:03:20+00:00Added an answer on June 14, 2026 at 7:03 pm

    Change this:

     cursor.moveToNext();
        if (cursor.getCount() > 0) {
            user.put("name", cursor.getString(1));
            user.put("password", cursor.getString(3));
            user.put("email", cursor.getString(2));
            user.put("regId", cursor.getString(4));
            user.put("unique_id", cursor.getString(5));
            user.put("course1", cursor.getString(6));
            user.put("course2", cursor.getString(7));
            user.put("course3", cursor.getString(8));
            user.put("course4", cursor.getString(9));
            user.put("course5", cursor.getString(10));
            user.put("course6", cursor.getString(11));
        }
    

    To this:

    if (cursor.moveToFirst()) {
            do {
    
                user.put("name", cursor.getString(1));
                user.put("password", cursor.getString(3));
                user.put("email", cursor.getString(2));
                user.put("regId", cursor.getString(4));
                user.put("unique_id", cursor.getString(5));
                user.put("course1", cursor.getString(6));
                user.put("course2", cursor.getString(7));
                user.put("course3", cursor.getString(8));
                user.put("course4", cursor.getString(9));
                user.put("course5", cursor.getString(10));
                user.put("course6", cursor.getString(11));
            } while (cursor.moveToNext());
        }
    

    cursor.moveToFirst() moves the cursor to the first row and returns false if the cursor is empty.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having a problem trying to return field names from an MSSQL database via odbc
I am trying to get started with PEAR's HTML_QuickForm but I'm having a problem.
I am having a bit of a problem, I am trying to get a
The main problem I'm having is trying to get the total wins loses and
I am having trouble trying to get a click event to fire after the
I'm having the following problem when trying to get the path of a given
I'm trying to get plaxo's Address Book Access working. I'm having the following problem:
I am having a problem when trying to get jquery to close an open
Does anybody know how to get around to following problem....... i am trying to
Hello I am having a problem with Django trying to get it deployed on

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.