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 8212533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:47:25+00:00 2026-06-07T10:47:25+00:00

So I’ve been working on setting up an SQL Databse of words, which as

  • 0

So I’ve been working on setting up an SQL Databse of words, which as far as I can tell from debug logs, actually does load and set up properly. However, when I try to query it, regardless of whether it is in the process of set-up or already done, my program is forced closed because of an exception. Investigation of the log reveals this:

07-12 13:47:02.000: W/dalvikvm(5247): threadid=1: thread exiting with uncaught exception
(group=0x40a401f8)
...
07-12 13:47:02.010: E/AndroidRuntime(5247): Caused by:
android.database.sqlite.SQLiteBindOrColumnIndexOutOfRangeException: bind or column index out of
range: handle 0x14a6548
...
07-12 14:41:36.250: E/AndroidRuntime(6326):     at com.example.wordsearchandroid.WordListProvider.query(WordListProvider.java:70)

A search of SQLiteBindOrColumnIndexOutOfRangeException on the Android API reveals a fairly… spartan page (http://developer.android.com/reference/android/database/sqlite/SQLiteBindOrColumnIndexOutOfRangeException.html) that mentions nothing of what the “handle” refers to.

Unfortunately, as far as I can tell, nothing in my queries is referring to non-existent columns. This is my query method in my ContentProvider:

public class WordListProvider extends ContentProvider {
private WordListOpenHelper listOpenHelper;
....

public static final String ID = "_ID";
public static final String WORD = "WORD";
public static final String LENGTH = "LENGTH";
...

public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    SQLiteQueryBuilder qBuilder = new SQLiteQueryBuilder();
    qBuilder.setTables(DB_NAME);
    Cursor c;

    switch(matcher.match(uri)) {

        case SEARCH_WORD_LIST:

            Log.d("WORDLISTPROVIDER", "Entered Search");
            c = qBuilder.query(listOpenHelper.getReadableDatabase(), projection, null,
                    selectionArgs, null, null, null);
            Log.d("WORDLISTPROVIDER", "Query Completed");
            if (c == null)
                return null;
            c.setNotificationUri(getContext().getContentResolver(), uri);
            break;

            default:
                Log.d("WORDLISTPROVIDER", "Default Entered");
                throw new IllegalArgumentException("Unknown URI " + uri);

    }
    Log.d("WORDLISTPROVIDER", "Exited Search");
    return c;
}

^The exception occurs at the line

c = qBuilder.query(listOpenHelper.getReadableDatabase(), projection, null,
                    selectionArgs, null, null, null);

For reference, here is how the projection and selectionArgs strings for this particular call are set:

String[] proj = {
            WordListProvider.ID,
            WordListProvider.WORD
    };
String[] selectionArgs = {""};

And here is the builder for my database, which is an inner class in WordListProvider:

private static class WordListOpenHelper extends SQLiteOpenHelper {

    private SQLiteDatabase wordDb;
    private Context helperContext;

    private static final String WORD_LIST_CREATE = "CREATE TABLE "+ DB_NAME  +
            " ( " +
             ID +  " INTEGER PRIMARY KEY, " +
             WORD + " TEXT, " +
            LENGTH + " INTEGER " +
            ");";

    WordListOpenHelper(Context context) {
        super(context, "wordlist", null, 1);
        helperContext = context;
        Log.d("OPENHELPER", "Constructed");
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        Log.d("OPENHELPER", "Creating");
        wordDb = db;
        Log.d("OPENHELPER", "DB set");
        wordDb.execSQL(WORD_LIST_CREATE);
        Log.d("OPENHELPER", "SQL Execed");
        loadWordList();
    }

    private void loadWordList() {
        new Thread(new Runnable() {
            public void run() {
                try {
                    loadWords();
                } catch (IOException e) {
                    Log.d("OPENHELPER", "Exception Caught");
                    throw new RuntimeException(e);
                }
            }
        }).start();
    }

    private void loadWords() throws IOException {
        ...
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        ...
    }



}

loadWords does finish eventually, but I get the exception whether the table has finished loading or not (sometimes the table will not have finished loading, I’ll get the exception, and the program will quit. The table will then finish loading). Also, my column names are consistent, at least they outwardly appear to be–and the exception even occurs if I pass a null (aka return all rows) for the projection to the query; Anyone have any ideas of what could be causing the exception, or what the handle means?

  • 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-07T10:47:27+00:00Added an answer on June 7, 2026 at 10:47 am

    Please, check this line in your provider:

    c = qBuilder.query(listOpenHelper.getReadableDatabase(), projection, null,
                        selectionArgs, null, null, null);
    

    You use selectionArgs without selection parameter. If You pass not null selectionArgs query will fail because there is no place where selection arguments can be bind to.

    This line should looks like this:

     c = qBuilder.query(listOpenHelper.getReadableDatabase(), projection, selection,
                            selectionArgs, null, null, null);
    

    You can’t use selectionArgs without selection, so try to pass null instead of

    String[] selectionArgs = {""};
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I would like to run a str_replace or preg_replace which looks for certain words
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.