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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:11:07+00:00 2026-05-28T03:11:07+00:00

Hello me again ( sorry ) I’m tiring to populate spinner from sqlitle and

  • 0

Hello me again ( sorry )

I’m tiring to populate spinner from sqlitle and it is working fine BUT my table looks like:

_id | Name | Time | ….

_id: is self incremental number always unique
Name: is name of person, repeats on many lines in this table

I want to put in spinner all names from this row but uniq no duplicates.
how I’m doing it now:

private void updateSpiner(){
Spinner nameSpinner = (Spinner) findViewById(R.id.spinMena);

    Cursor nameCursor = db.getNames();
    startManagingCursor(nameCursor);

    String[] from = new String[]{"Name"}; 
    int[] to = new int[]{android.R.id.text1};

    SimpleCursorAdapter nameAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, nameCursor, from, to);
            nameSpinner.setAdapter(nameAdapter);
        }

here is how I get the data:

public Cursor getNames(){
        final String KEY_TITLE = "Name";
        final String KEY_ROWID = "_id";
        return database.query("plan", new String[] {KEY_ROWID, KEY_TITLE}, null, null, null, null, null);
    }

can somebody explain to me why I need to get also _id row for this, I’m still now to Java and I don’t see why I need it, except if I don’t do it it will complain that there is no _id.

Buts it is not used in first method I get only Names from it… because of _id I can’t use in query DISTINCT = true because it still return all rows as _id is unique for each line..

Could someone help me to wrap my head around it ? I don’t want to make separate table or something..

Thanks,
Vlad

  • 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-28T03:11:08+00:00Added an answer on May 28, 2026 at 3:11 am

    In my case, I couldn’t get this work with SimpleCursorAdapter, What I had to do was, use ArrayAdapter instead of simplecursoradapter and add DISTINCT clause in the query after removing ID field from the query. Here is link for discussion on Why _id field required for simplecursor adapter

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

Sidebar

Related Questions

again, sorry for my silly question, but it seems that what i've learned from
Hello again ladies and gents! OK, following on from my other question on ASP.NET
sorry for asking this question again but i didnt get much help on the
Hello Again my fellow programmers out there, I'm designing and programming from scratch a
Hello again; i need to show X,Y,Risk in ListBoxes. But i can not do
Hey, sorry to bother you again, but I can't get this to work and
Hello again Stackoverflow people! Assume I have these words: smartphones, smartphone I want to
Hello I've runned in to a problem again that I can't solve on my
Hello I am compiling a program with make but I get the error of
Hello , I am currently working on the student association's website. The student's association

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.