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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:31:44+00:00 2026-05-31T01:31:44+00:00

I fetch data in table. but i need to delete it when user click

  • 0

I fetch data in table. but i need to delete it when user click on record or row but
when i click on number 2 position record it delete 3 re record.. but i need to delete
record in which user click. pls provide me some hint or tutorial.
thank you..
here is my sample code.

 public class MyTable extends Activity {

int counter=0;
 MySQLiteHelper m=new MySQLiteHelper(this);
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.locprofile);



      // Reading all contacts
    final MySQLiteHelper m=new MySQLiteHelper(getBaseContext());
    final List<LocWiseProfileBeans> LocWiseProfile= m.getAllLocWiseProfile();       

    for (final LocWiseProfileBeans cn : LocWiseProfile) {
        // get a reference for the TableLayout
        TableLayout table = (TableLayout) findViewById(R.id.locprofile_table);

        // create a new TableRow
        TableRow row = new TableRow(this);

        // count the counter up by one
        counter++;


        String log = "Loc Name: "+cn.getLocname()+" ,Lattitude: " + cn.getLattitude()+ " ,Longitude: " + cn.getLongitude()+ " , Selected Profile :"+cn.getSelectedprofile()+"id:"+cn.getId();
        TextView t = new TextView(this);

       //final int Id=cn.Id;
        // set the text to "text xx"
        t.setText(cn.getLocname());

        TextView t2 = new TextView(this);
        t2.setText(cn.getSelectedprofile());



        row.setTag(counter);  //  use counter or index for tag, so you can get the data from LocWiseProfile later
        row.setOnClickListener(new View.OnClickListener() 
        {

            @Override
            public void onClick(View v) 
            {
                try{
                int tag = (Integer)v.getTag();
                LocWiseProfileBeans cn = LocWiseProfile.get(tag);
                    int value=cn.getId();
                    m.delete(value);
                    deleteMessage();

                }catch(Exception e){}

                /*LocWiseProfileBeans lc=new LocWiseProfileBeans();
                int tag=(Integer)lc.getId();
                LocWiseProfileBeans value=LocWiseProfile.get(tag);
                //if(value.Id);
                m.delete(value.Id);
                deleteMessage();*/

            }
        });
  • 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-31T01:31:45+00:00Added an answer on May 31, 2026 at 1:31 am

    Because you are incrementing the counter variable before setting as a tag on a row.
    So you there is a position 1 for row 1 and probably this is the reason for deleting the wrong row.

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

Sidebar

Related Questions

I need to make an excel file which would fetch data from connection to
I've got two tables from which I need to extract information, but the data
Need to fetch data from a few tables -table one has all product details
I'm fetching some data from an MSSQL table using the mssql_fetch_object, but the text
The situation: I fetch a complete table from my sqllite core data database and
What do I do, I need to fetch data from 3 tables in mysql,
Im using vb.net and I need to fetch data from two different tables and
My application often fetch data from a webpage using WebRequest, but it isn't possible
I have the following Query and i need the query to fetch data from
Usually, I need to retrieve data from a table in some range; for example,

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.