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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:59:09+00:00 2026-06-15T04:59:09+00:00

How can I provide suggestions for an AutoCompleteTextView from a column in a database

  • 0

How can I provide suggestions for an AutoCompleteTextView from a column in a database table which may have some values repeated?

http://www.outofwhatbox.com/blog/2010/11/android-autocompletetextview-sqlite-and-dependent-fields/

http://www.outofwhatbox.com/blog/2010/11/android-simpler-autocompletetextview-with-simplecursoradapter/

In learning how to use AutoCompleteTextView, I ran across the above two blog articles. These are great for an introduction but don’t quite solve my problem. I want to provide the distinct values of a column from my database as the suggestions for a AutoCompleteTextView in my app. When I implement the code from the above two examples, I get repeated suggestions in my list. Trying to use the DISTINCT keyword in my query doesn’t work because CursorAdapter requires an _id field in the returned results. Since each row has its own _id, the repeated values are not eliminated.

I am considering creating a separate lookup table for the values. This has the benefit of normalizing my data as well as providing easy access to the distinct values to suggest for entries. For one of my AutoCompleteTextViews, I think this will work well because there are most likely only 4 or 5 different values that will be used. For another, it might not work as well because I’m not sure how many distinct values there will be in a large data set.

  • 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-15T04:59:10+00:00Added an answer on June 15, 2026 at 4:59 am

    If you have a table:

    CREATE TABLE Foo(_id INTEGER PRIMARY KEY, bar TEXT);
    

    And want to select only one _id for each distinct bar you can use:

    SELECT _id, bar FROM Foo GROUP BY bar;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone help or provide me with some suggestions for the below query. I
I would like to create a List Box which can provide me suggestions.The exact
wanted to see if somebody can provide some suggestions/pointers on how to address this
I have a AutoCompleteTextView which gives user auto-completion search result from Google Places API
Hope the AWK gurus can provide a solution to my problem . I have
I am looking for a library or database that can provide guesses about whether
What are three ways in which web applications can provide a stateful experience for
I have an ASP.NET MVC view which contains some plain html. I wanna use
I have an ASP.NET MVC3 application that uses entities generated from a database. Each
I have a list, which may be empty or non-empty. I want to create

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.