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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:10:00+00:00 2026-05-27T23:10:00+00:00

I have a listview linked to a sqlite database. I have 3 items in

  • 0

I have a listview linked to a sqlite database. I have 3 items in the database, but everytime I click on the second and third value it gives me the same result as the very first value in the record set. How do I move through subsequent items in the recordset? Here is the code:

            DBAdapter db = new DBAdapter(this);
    db.open();

    lv = (ListView)findViewById(R.id.list);

    //Get cursor for list items
    cursor = db.getAllChannels();


    lv.setOnItemClickListener(new OnItemClickListener(){


        public void onItemClick(AdapterView<?> arg0, View arg1,
                int position, long arg3) {


            //String cText = lv.getItemAtPosition(position).toString();

            //retrieve database values
            Toast.makeText(getApplicationContext(), cursor.getString(cursor.getColumnIndex(DBAdapter.KEY_STATIONURL)), Toast.LENGTH_SHORT).show();

        }

    });
  • 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-27T23:10:00+00:00Added an answer on May 27, 2026 at 11:10 pm

    When the adapter is already populated using a cursor, you should refrain from acquiring data using the cursor fed to the adapter. Instead use getItem(int position) which should return a cursor that is already pointed to the correct item in your list. Your code would then look like this:

    lv.setOnItemClickListener(new OnItemClickListener(){
    
    
            public void onItemClick(AdapterView<?> arg0, View arg1,
                    int position, long arg3) {
    
                //retrieve database values
                Cursor tempCursor = getItem(position);
                Toast.makeText(getApplicationContext(), tempCursor.getString(tempCursor.getColumnIndex(DBAdapter.KEY_STATIONURL)), Toast.LENGTH_SHORT).show();
    
            }
    
        });
    

    You can go a step further and override your CursorAdapter’s getItem(position) so that it returns a Data* object wherein you just need to getKeyStationUrl()* to get the value that you need.

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

Sidebar

Related Questions

I have a ListView which sometimes I need to put around 10000 items in.
I have an ArrayList of items that are linked to a custom Adapter. The
I have Listview on WinForm I need to have two columns but without headers,
I'm having an issue where I have 2 DataPagers on the same page, linked
I have a two-column ListView linked to a Datapager. The ListView lists all files
If I create multiple ListView s with the same ItemsSource they become strangely linked.
I have listview that binds from sqlite and groups by KEY_TITLE(field) so i need
I have a listview that you select a row/item on. This is linked to
I have listview with some listadapter after click on item from list I'd like
i have listview the fisrt time i when i click to row it open

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.