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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:25:27+00:00 2026-06-05T09:25:27+00:00

I have 1-50 records in the database. I am fetching those data using cursor

  • 0

I have 1-50 records in the database. I am fetching those data using cursor and set those values to Spinner using Simple Cursor Adapter. Now what i need is i want to set one value say 39th value as default. But not by its position i want to set by its value.

I know how to set the spinner default by its position

   spinner.setSelection(39) 

will set the spinner to that value.

But i didn’t have any idea about setting the spinner default by its value(text) in the database.
I know the values in the database. For eg “books” is one of the value in the spinner. I need to set the spinner default as books.

Is there any possible way to do this?

  • 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-05T09:25:28+00:00Added an answer on June 5, 2026 at 9:25 am

    Finally, i solved the problem by using following way, in which the position of the spinner can be get by its string

    private int getPostiton(String locationid,Cursor cursor)
    {
        int i;
        cursor.moveToFirst(); 
        for(i=0;i< cursor.getCount()-1;i++)
        {  
    
            String locationVal = cursor.getString(cursor.getColumnIndex(RoadMoveDataBase.LT_LOCATION));  
            if(locationVal.equals(locationid))
            { 
                position = i+1;  
                break;
            }
            else
            {
                position = 0;
            }
            cursor.moveToNext();  
        } 
    

    Calling the method

        Spinner location2 = (Spinner)findViewById(R.id.spinner1);
        int location2id = getPostiton(cursor.getString(3),cursor);
        location2.setSelection(location2id);
    

    I hope it will help for some one..

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

Sidebar

Related Questions

Suppose i have 1kk records in my database. Now i need to select some
I am fetching records from MySQL database using Java (JDBC). I have tables -
I have records in the database with the sort order number. Now I want
I have stored various records in the MySql database orkut. Now I want to
I have a Datatable which is fetching ~5,50,000 records from database(SQLite). When fetching it
I have a form i am fetching many records from database that are rendering
I have an problem in fetching records from database with php. I have 31700
I have 3 records in my database (for testing purposes) and I am using
I have like 400 records on my database, suppose this is the first version
i have total 70,000 records in database. currently i displays all the records in

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.