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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:18:57+00:00 2026-05-31T22:18:57+00:00

I need to create a drop down list (spinner) in eclipse for Android whereby

  • 0

I need to create a drop down list (spinner) in eclipse for Android whereby the drop down options can be created by the user.

To do this I’ve created a SQLiteDatabase, which I want to convert into a string array to be put into an array adapter, which can then be fed into the spinner.

Database details are:

DATABASE_NAME = “carddb”
DATABASE_TABLE = “cardtable”

Then the column I wish to read the values from is:
KEY_CARDDETAILS = “_carddetails”;

Here is my code so far, adapted from another question on this site (Link: how to get the database value to a String array in android(sqlite Database))

myDB = cardtable.this.openOrCreateDatabase(“carddb”, MODE_PRIVATE, null);
Cursor cardcursor = cardDB.rawQuery(“SELECT * FROM cardtable”);

        String[] cardstringarray = new String[cardcursor.getCount()];
           cardcursor.moveToFirst();   

           int counter = 0;
           while(cardcursor.moveToNext()){
               String carddetailss = cardcursor.getString(cardcursor.getColumnIndex("NAME"));
               cardstringarray[counter] = carddetailss;
               counter++;
            }

I’m getting an error under “myDB” and “cardtable”, both errors saying they cannot be resolved into a variable!

PLEASE HELP!

  • 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-31T22:18:58+00:00Added an answer on May 31, 2026 at 10:18 pm

    Use this code

    String[] displayName={};
    ArrayList<String> List=new ArrayList<String>();
    myDB = cardtable.this.openOrCreateDatabase("carddb", MODE_PRIVATE, null); Cursor cardcursor = cardDB.rawQuery("SELECT * FROM cardtable");
    
        String[] cardstringarray = new String[cardcursor.getCount()];
           cardcursor.moveToFirst();   
    
           int counter = 0;
           while(cardcursor.moveToNext()){
               String carddetailss = cardcursor.getString(cardcursor.getColumnIndex("NAME"));
               List.add(carddetailss);
               counter++;
            }
        if(List != null){
        listEmail=(ListView)findViewById(R.id.listEmail);
        listEmail.setVisibility(view.VISIBLE);
        displayName=(String[])List.toArray(new String[0]);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, android.R.id.text1, displayName);
        // Assign adapter to ListView
        listEmail.setAdapter(adapter);
        }
    

    This is work for you. Use spinner instead of listView.

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

Sidebar

Related Questions

I need to create a drop down menu in struts2 from List. How can
I need some help please. I need to create a drop down list and
I need to dynamically create in PHP a drop-down list of numerical choices like
I need to create a dropdown, which can contain 100s of options. I need
I need to create an HTML drop down that will display flags of countries.
I need to add a combo box or drop-down list to a UIView. I
Lets say that I have a drop down list that I want to create
I need to create a drop down menu where I need to display 5
I need to be able to clone a drop down list and filter only
Hi I am trying to make a dynamically created drop down list in grails

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.