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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:22:08+00:00 2026-06-03T23:22:08+00:00

Cursor smCursor = getContentResolver().query( Uri.parse(content://contact), new String[] { _id, address, body }, address like?,

  • 0
  Cursor smCursor = getContentResolver().query( 
            Uri.parse("content://contact"),
            new String[] { "_id", "address", "body" }, "address like?",
            new String[] { searchContactPhone }, null); 
CustomAdapter ada = new CustomAdapter(this,
                R.layout.sm_layout, smCursor, new String[] {
                        "body" }, new int[] {
                        R.id.txt2 });
        lvSm.setAdapter(ada);

btnDel.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {


            ArrayList<Boolean> ca = ada.getItemsThatAreChecked();
            // this ArrayList will hold our Strings from the rows that were clicked.
            ArrayList<String> results = new ArrayList<String>();
            int s = ca.size();
            for (int i = 0; i < s; i++) {
                    if (ca.get(i).booleanValue()) {
                            smCursor.moveToPosition(i);
                            Log.v("sss", smCursor.getString(smCursor.getColumnIndex("_id")));
                            results.add(smCursor.getString(smCursor.getColumnIndex("_id")));
                    }
            }
            if(results != null && !results.isEmpty()){
                String [] mSelectionArgs  = results.toArray(new String[results.size()]);
                String mSelectionClause = "_id=?";
                int delCursor = 0;

                Uri uri = Uri.parse("content://contact");
                for(int delCount = 0;delCount < mSelectionArgs.length;delCount++)
                {
                delCursor = getContentResolver().delete(uri ,mSelectionClause,new String[]{mSelectionArgs[delCount]});
                }
                ada.notifyDataSetChanged();
                Toast.makeText(getApplicationContext(), mSelectionArgs.length +" number of rows deleted", 5).show();

            }
            else
                Toast.makeText(getApplicationContext(), "Sorry no deletion occurs", 5).show();


        }

I want to know that how can i update my list view, as i am deleting the selected items from my list view and after deletion the selection automatically takes place to next items.I have used the notifyDataSetChanged() but not works. I am using the Custom adapter.

  • 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-03T23:22:12+00:00Added an answer on June 3, 2026 at 11:22 pm
    btnDel.setOnClickListener(new View.OnClickListener() {
    
            public void onClick(View v) {
    
    
                ArrayList<Boolean> ca = ada.getItemsThatAreChecked();
                // this ArrayList will hold our Strings from the rows that were clicked.
                ArrayList<String> results = new ArrayList<String>();
                int s = ca.size();
                for (int i = 0; i < s; i++) {
                        if (ca.get(i).booleanValue()) {
                                smCursor.moveToPosition(i);
                                Log.v("sss", smCursor.getString(smCursor.getColumnIndex("_id")));
                                results.add(smCursor.getString(smCursor.getColumnIndex("_id")));
                        }
                }
                if(results != null && !results.isEmpty()){
                    String [] mSelectionArgs  = results.toArray(new String[results.size()]);
                    String mSelectionClause = "_id=?";
                    int delCursor = 0;
    
                    Uri uri = Uri.parse("content://contact");
                    for(int delCount = 0;delCount < mSelectionArgs.length;delCount++)
                    {
                    delCursor = getContentResolver().delete(uri ,mSelectionClause,new String[]{mSelectionArgs[delCount]});
                    }
            ada = new CustomAdapter(this,
                    R.layout.sm_layout, smCursor, new String[] {
                            "body" }, new int[] {
                            R.id.txt2 });
            lvSm.setAdapter(ada);
    
                    Toast.makeText(getApplicationContext(), mSelectionArgs.length +" number of rows deleted", 5).show();
    
                }
                else
                    Toast.makeText(getApplicationContext(), "Sorry no deletion occurs", 5).show();
    
    
            }
    

    Just working fine, as I only recreate the instance of custom adapter and bind it to list view after deletion.

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

Sidebar

Related Questions

Cursor searchCursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[] {_id,Phone.DISPLAY_NAME}, Phone.DISPLAY_NAME + like ?, new String[]{ %
private Cursor getContacts() { // Run query Uri uri = ContactsContract.Contacts.CONTENT_URI; String[] projection =
Cursor findNormalItems = db.query(items, columns, type=?, new String[] { onSale }); I want to
public Cursor fetchTimetable() { return mDb.query(DATABASE_TABLE_TIMETABLE, new String[] {TIMETABLE_ROWID, TIMETABLE_MODULECODE, TIMETABLE_MODULENAME, TIMETABLE_ROOM, TIMETABLE_LECTURER, TIMETABLE_TIME},
Cursor mCursor = mDb.query(true, CUSTOMER_TABLE_NAME, new String[] {GENERIC_ID_KEY, ADDRESS_KEY, PHONE_KEY, EMAIL_KEY,CUSTOMER_NAME_KEY}, GENERIC_ID_KEY + =
From my main.java: Cursor c = db.getDue(); String[] columns = new String[] { _id,
Cursor cursor = resolver.query( Data.CONTENT_URI, DataQuery.PROJECTION, DataQuery.SELECTION, new String[] {String.valueOf(rawContactId)}, null); With PROJECTION being:
Having this line Cursor c = db.rawQuery(PRAGMA table_info(?), new String[] {tableName}); and getting this:
Cursor curz=mDbHelper.fetchAllRemindersG(); startManagingCursor(curz); ArrayList<String> mArrayList = new ArrayList<String>(); String name =curz.getString(curz.getColumnIndex(DatabaseIN.KEY_TITLE)); for(curz.moveToFirst(); curz.moveToNext(); curz.isAfterLast())
I am trying this Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); Cursor cursor1

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.