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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:21:02+00:00 2026-05-23T01:21:02+00:00

Hello Everyone I am new being in ANDROID so I am getting one problem

  • 0

Hello Everyone I am new being in ANDROID so I am getting one problem during developing an app using SQLite database. I retrieved some data columns from SQLite database table, stored them in an ArrayList and displayed them using ListActivity. Then I made a nice looking listview filter also. Now after filtering I called onListItemClick method and after clicking any position, I am getting stuck in retrieving rowId of a particular listitem of filtered listview in listActivity and to store it in an integer variable.

Can anyone HELP me to know how it is possible.

Any Ideas? I need example code snippets…!!

My Code:

package com.aman.samples.dbdemo;

import java.util.ArrayList;
import com.aman.samples.dbdemo.helpers.DatabaseHelper;
import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Filterable;
import android.widget.ListAdapter;
import android.widget.ListView;

public class Searching extends ListActivity {

    public static final String KEY_ROWID = "RowId";
    private final String DB_NAME="Database.sqlite"; // data base name 
    private final String TABLE_NAME="Physics";   // table name  
    private SQLiteDatabase myDataBase;
     ArrayAdapter<String> adapter;
    EditText filterText;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.searching);

        final ArrayList<String> list=new ArrayList<String>();


        myDataBase=this.openOrCreateDatabase(DB_NAME, MODE_PRIVATE, null);
        DatabaseHelper dbHelper = new DatabaseHelper(getApplicationContext());
        dbHelper.openDataBase();

        Cursor c=myDataBase.rawQuery(" select * from "+TABLE_NAME,null);
        if(c!=null)  // if c value is not null 
        {
            if(c.moveToFirst())  // movies first column 
            {
                do
                {
                    String nam=c.getString(c.getColumnIndex("Law")); // getting specific values regarding column index 
                //  int age=c.getInt(c.getColumnIndex("age"));
                    list.add(" "+nam);

                }while(c.moveToNext()); // move to next row

            }
        }


         filterText = (EditText) findViewById(R.id.search_box);
        filterText.addTextChangedListener(filterTextWatcher);


        adapter=new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, 
                list);
        setListAdapter(adapter);


    }

    private TextWatcher filterTextWatcher = new TextWatcher() {

        @Override
        public void afterTextChanged(Editable arg0) {
            // TODO Auto-generated method stub

        }

        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
        }

        public void onTextChanged(CharSequence s, int start, int before,
                int count) {

            adapter.getFilter().filter(s);
        }



    };

    @Override
    protected void onDestroy() {
        super.onDestroy();
        filterText.removeTextChangedListener(filterTextWatcher);
    }

    protected void onListItemClick(ListView l,View v,int position,long id){
        super.onListItemClick(l, v, position, id );





        if(position==0)
        {

                   Integer rowId = .........// I WANT A SOLUTION OR METHOD TO RETRIEVE ROW ID OF PARTICULAR LISTITEM IN LISTACTIVITY DISPLAYING DATAS FROM SQLITE DATABASE TABLE


            String s=Integer.toString(rowId);

            Intent i=new Intent(this,FinalView.class);
            i.putExtra("key1", s);
            startActivity(i);
        }
        if(position==1)
        {

         Integer rowId = .........// I WANT A SOLUTION OR METHOD TO RETRIEVE ROW ID OF PARTICULAR LISTITEM IN LISTACTIVITY DISPLAYING DATAS FROM SQLITE DATABASE TABLE

            String s=Integer.toString(rowId);

            Intent i=new Intent(this,FinalView.class);
            i.putExtra("key1", s);
            startActivity(i);
        }
        if(position==2)
        {

               Integer rowId = .........// I WANT A SOLUTION OR METHOD TO RETRIEVE ROW ID OF PARTICULAR LISTITEM IN LISTACTIVITY DISPLAYING DATAS FROM SQLITE DATABASE TABLE
            String s=Integer.toString(rowId);
            Intent i=new Intent(this,FinalView.class);
            i.putExtra("key1", s);
            startActivity(i);
        }
    }
}

Thanks in Advance.

  • 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-23T01:21:03+00:00Added an answer on May 23, 2026 at 1:21 am

    You should use SimpleCursorAdapter in order to populate list with data from DB. In that case “id” parameter of onListItemClick(l, v, position, id ) will hold id of record.

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

Sidebar

Related Questions

Hello everyone I am new to blackberry and I want a textfield that scroll
hello everyone i am new bie in iphone development i want to connect to
Hello everyone and thanks in advance. I have a problem and I have 2
Hello there and Merry Christmas !!! I am new to WPF and I am
Hello everyone I'm currently having 2 issues with the code below: Upon return of
hello everyone it is me again! i've got few problems too. i am deveoping
Hello everyone I'm trying to improve my Java skills by solving some problems from
Hello everyone I am trying to resize an image of 700kb with imagecreatefromjpeg. This
Hello everyone here is my DAO class : public class UsersDAO extends HibernateDaoSupport {
Introduction : Hello Everyone, I have been looking for days for a way to

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.