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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:41:14+00:00 2026-05-17T18:41:14+00:00

how can i use an Array of strings to query an sqlite database? i

  • 0

how can i use an Array of strings to query an sqlite database? i keep getting the exception “SQliteException: bind or column index out of range”.

      String[] names = new String[values.size()]; // values is an Arraylist
      String[] condition = values.toArray(names);
Cursor row = db.query(true,DATABASE_TABLE, resultColumns, NAME +"=" + "?", condition, null, null, null,null);

please any help will be greatly appreciated as usual. Thanks

P.S values, which is the Arraylist is being poplulated through a loop so i can’t have a defined size. thats why i can’t use the get() method and seperate the elements in it by commas’ which would have been easier.

  • 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-17T18:41:14+00:00Added an answer on May 17, 2026 at 6:41 pm

    Your query’s where clause is where name = ?. This expects the passed-in array to be of size 1. Judging by its name (names), I’m guessing its not. You need to rethink what you want your SQL query to be (maybe where name in ...).

    E.g.:

    final String whereClause = NAME + " in (" + convertToCommaDelimitedString(values) + ")"; 
    db.query(true,DATABASE_TABLE, resultColumns, whereClause, null, null, null, null,null);
    

    You need to implement String convertToCommaDelimitedString(Collection c);

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

Sidebar

Related Questions

Can split(string, array, separator) in awk use sequence of whitespaces as the separator (or
You can use arrays with str_replace(): $array_from = array ('from1', 'from2'); $array_to = array
To access the array indice at the xth position we can use some sort
If I want a part of an array I can use [] or split
If I want to add a value in an array, I can use: $array[]
How can I use std::shared_ptr for array of double? Additionally what are advantages/disadvantages of
How can I use the counter value to multiply the frogs in the array?
I can create and use dynamic two dimensional array in Fortran (in 77 standard).
When shall i use malloc instead of normal array definition in C? I can't
I am using db_placeholder within a query to replace an array of strings. $paths

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.