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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:20:47+00:00 2026-05-21T07:20:47+00:00

I’m having a issue where when I go to the next activity and pass

  • 0

I’m having a issue where when I go to the next activity and pass then data with the intent it is only showing me the last entry off the DB and not the clicked items info.

.java

public class TimsFavs extends ListActivity implements OnItemClickListener {

/** Called when the activity is first created. */
ArrayList<String> results = new ArrayList<String>();

// Database results
String col0,col1,col2,col3,col4,col5,col6,col7;

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.timsfavs);
    DBAdapter db = new DBAdapter(this);

    //---get all Locations---
    db.open();

    Cursor c =  db.getAllLocation();

    if (c.moveToFirst())
    {
        do {

            col0 =  c.getString(c.getColumnIndex(DBAdapter.KEY_ROWID));
            col1 =  c.getString(1);
            col2 =  c.getString(2);
            col3 =  c.getString(3);
            col4 =  c.getString(4);
            col5 =  c.getString(5);
            col6 =  c.getString(6);
            col7 =  c.getString(7);

            results.add(col0);

        } while (c.moveToNext());
    }
    db.close();

    setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,results));
    ListView lv;
    lv = getListView();
    lv.setTextFilterEnabled(true);
    lv.setBackgroundColor(Color.rgb(83, 05, 14));
    lv.setOnItemClickListener((OnItemClickListener) this);

}

public void onItemClick(AdapterView<?> TimsFavs, View view, int position, long id) {

    Intent i = new Intent(getApplicationContext(), TimsFavsMore.class);

    i.putExtra("ct_id_pass", col0);
    i.putExtra("ct_storeid_pass", col1);
    i.putExtra("ct_address_pass", col2);
    i.putExtra("ct_city_pass", col3);
    i.putExtra("ct_province_pass", col4);
    i.putExtra("ct_country_pass", col5);
    i.putExtra("ct_pcode_pass", col6);
    i.putExtra("ct_phnum_pass", col7);

    startActivity(i);
    finish();

}

}

and my other activity is

`public class TimsFavsMore extends Activity {
DBAdapter db = new DBAdapter(this);

String rowId;

 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.timsfavsmore);

        Intent i = getIntent();
        Bundle b = i.getExtras();

         final String rowId = b.getString("ct_id_pass");
         final String phnum = b.getString("ct_phnum_pass");
         final String storeid = b.getString("ct_storeid_pass");
         final String address = b.getString("ct_address_pass");
         final String city = b.getString("ct_city_pass");
         final String province = b.getString("ct_province_pass");
         final String country = b.getString("ct_country_pass");
         final String pcode = b.getString("ct_pcode_pass");

        TextView title = (TextView) findViewById(R.id.textview);
        title.setText(Html.fromHtml("<br>Row ID: " + rowId + "<br><b><u>Location Address:</u></b><br><br>Store #" + storeid + "<br><br>" + address + "<br>" + city + ", " + province + "<br>" + country +"<br>" + pcode +"<br><br><b><u>Contact Info:</b></u><br><br>" + phnum +"<br>"));

// open to Nav

final Button button1 = (Button) findViewById(R.id.gohere);
button1.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {

        String uri = "google.navigation:q=Tim%20Hortons,%20" + address + ",%20" + city + ",%20" + province + ",%20" + pcode + "";
        Intent i2 = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        startActivity(i2);

    }
});

// open to maps

final Button button2 = (Button) findViewById(R.id.showmap);
button2.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {

        String uri2 = "geo:0,0?q=Tim%20Hortons,%20" + address + ",%20" + city + ",%20" + province + ",%20" + pcode + "";
        Intent i3 = new Intent(Intent.ACTION_VIEW, Uri.parse(uri2));
        startActivity(i3);

    }
});

// Add to My Timmies List

final Button button3 = (Button) findViewById(R.id.removefav);
button3.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {

      //---add 2 SQLite---

        db.open();

        if (db.deleteLocation(rowId))
            Toast.makeText(getApplicationContext(), " Delete successful.", 
                Toast.LENGTH_LONG).show();
        else
            Toast.makeText(getApplicationContext(), "Delete failed.", 
                Toast.LENGTH_LONG).show();            
        db.close();

       Intent i = new Intent(getApplicationContext(), MyTimmies.class);
       startActivity(i);
       finish();

    }
});


final Button button4 = (Button) findViewById(R.id.favsdone);
button4.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {

   Intent i4 = new Intent(getApplicationContext(), MyTimmies.class);
       startActivity(i4);
       finish();

    }
});
 }

}`

Any Ideas?

  • 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-21T07:20:48+00:00Added an answer on May 21, 2026 at 7:20 am

    You are iterating through your cursor and assigning the values to your strings. when it completes the iteration, your strings only contain the last value you assigned and then you pass that.

    You should bind your list to a SimpleCursorAdapter instead of creating a whole different string array. Then in your onClickListener, you can just pass the key that identifies your row of data in the database.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.