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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:51:28+00:00 2026-06-14T21:51:28+00:00

I am using SQLiteDatabase in android. I am not able to refersh my listview

  • 0

I am using SQLiteDatabase in android. I am not able to refersh my listview after deleting a row.
My code is as follows:

    public void delete(String i) {
    // TODO Auto-generated method stub
    String [] columns= new String[]{KEY_ROW_ID,KEY_FHR,KEY_ID,KEY_NAME,KEY_AGE};
    Cursor c= our_db.query(KEY_TABLE, columns, null, null,null, null, null);
    our_db.delete(KEY_TABLE, KEY_NAME+ "="+"\'"+i+"\'", null) ;
    c.requery();

}

I call it from a viewholder in efficientadapter. Below is the code where I call it:

        holder.del.setOnClickListener(new OnClickListener() {
                private int pos=position;
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    final long newpos;
                    sql_get db = new sql_get(c);
                    db.open();

                    db.delete(DATA[pos]);               
                    notifyDataSetChanged();                     
                    db.close();
                }
            });

Can anyone help me finding out the problem. It doesn’t give any error. it just deleted the row but doesn’t update the view.

Here is the adapter i used:

    private static class EfficientAdapter extends BaseAdapter {
    private LayoutInflater mInflater;
    private Bitmap mIcon1;
    private Bitmap mIcon2;
    private Bitmap mIcon3;
    private Bitmap mIcon4;

    Context c;
    int window;

    public EfficientAdapter(Context context) {
        // Cache the LayoutInflate to avoid asking for a new one each time.
        mInflater = LayoutInflater.from(context);
        this.c=context;
        // Icons bound to the rows.
        mIcon1 = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon48x48_1);
        mIcon2 = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon48x48_2);
        mIcon3 = BitmapFactory.decodeResource(context.getResources(), R.drawable.del1);
        mIcon4 = BitmapFactory.decodeResource(context.getResources(), R.drawable.edit);
    }       
    public int getCount() {
        return DATA.length;
    }       
    public Object getItem(int position) {
        return position;
    }   
    public long getItemId(int position) {
        return position;
    }       
    public View getView(final int position, View convertView, ViewGroup parent) {
        // A ViewHolder keeps references to children views to avoid unneccessary calls
        // to findViewById() on each row.
        ViewHolder holder;
        //int i=0;


            convertView = mInflater.inflate(R.layout.list_item_icon_text, null);

            // Creates a ViewHolder and store references to the two children views
            // we want to bind data to.
            holder = new ViewHolder();
            holder.text = (TextView) convertView.findViewById(R.id.text);
            holder.icon = (ImageView) convertView.findViewById(R.id.icon);
            holder.del=(ImageView)convertView.findViewById(R.id.icon1);
            holder.edit=(ImageView)convertView.findViewById(R.id.icon2);

            window=position;
            holder.text.setOnClickListener(new OnClickListener() { 
                private int pos=position;

                //private int pos = position; 
                public void onClick(View v) { 

                    System.out.println(window);
                    sql_get db = new sql_get(c);
                    db.open();
                    String ret_id= db.getid(DATA[pos]);
                    String ret_name = db.getname(DATA[pos]);                        
                    String ret_age= db.getage(DATA[pos]); 
                    String ret_fhr= db.getfhr(DATA[pos]);                       
                    String[] result = {ret_id,ret_name,ret_age,ret_fhr};
                    db.close();
                    Bundle b=new Bundle();
                    b.putStringArray("key",result); 
                    Intent i =new Intent(c,Tabs.class);
                    i.putExtras(b);
                    c.startActivity(i)  ;
                    Toast.makeText(c, getItemId(position)+""+" Click- text " +pos+" "+ret_name, Toast.LENGTH_SHORT).show();
                } 
            });                 
            holder.del.setOnClickListener(new OnClickListener() {
                private int pos=position;
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    final long newpos;                      
                    sql_get db = new sql_get(c);
                    db.open();
                    db.delete(DATA[pos]);                       
                    notifyDataSetChanged();                     
                    db.close();                     
                    Toast.makeText(c, "deleting " + DATA[pos], Toast.LENGTH_SHORT).show();                      
                }
            });
            convertView.setTag(holder);
        }           
        holder.text.setText(DATA[position]);
        holder.icon.setImageBitmap((position & 1) == 1 ? mIcon1 : mIcon2);
        holder.del.setImageBitmap(mIcon3);
        holder.edit.setImageBitmap(mIcon4);
        return convertView;     
    static class ViewHolder {
        ImageView del;
        TextView text;
        ImageView icon;
        ImageView edit;
    }       
}
  • 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-14T21:51:30+00:00Added an answer on June 14, 2026 at 9:51 pm

    I found the solution. As said above, I had to change the DATA object.
    I used the following commands to achieve it.

    db.open();                                      
    db.delete(DATA[pos]);           
    DATA=db.getdata();
    DATA_NAME=db.getname();
    DATA_AGE=db.getage();
    DATA_FHR=db.getfhr();                                                   
    db.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

why SqlLite query in android produce Nullpointer exception I am using this code public
I'm making Android app that has this database in it: public void onCreate(SQLiteDatabase db)
How do I get the row count of a query in Android using SQLite?
I will need a code example; I'm not very experienced. I need a ListView
Using the typical SQLiteDatabase object in Android's API, what can I do to get
I'm trying to save a sound as a ringtone in Android using this code.
I am using this following code which creates a ListView with text and an
I was newbie in using sqlite database android. and now I have a problem
In my Android app, I want to use my existing sqlite database.I followed http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
I was developing android app on eclipse till now and now I'm using Mono

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.