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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:54:19+00:00 2026-05-24T04:54:19+00:00

hi frnds i have a button and a textview in a whole view,when i

  • 0

hi frnds i have a button and a textview in a whole view,when i click the button then all contact are sved in csv file but i wnt when these contact are going to csv file it update text as “exporting 3 (this count is changingmeans 1 2 3 4 5….till total no of contacts) contcts ” means text view is changing when i click button then how to do it

the code for getting total no. of contacts in phone is below…

      update:



                    @Override
        protected Boolean doInBackground(String... args) {
            int count;
            CSVWriter writer = null;
          try 
           {
            writer = new CSVWriter(new FileWriter(Environment.getExternalStorageDirectory().getAbsolutePath() + "/my_test_contact.csv"));
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
         }
        String displayName;
        String number;
        String emailid;
        long _id;

        String columns[] = new String[]{ ContactsContract.Contacts._ID,
                   ContactsContract.Contacts.DISPLAY_NAME };
        writer.writeColumnNames(); // Write column header
        Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,
                   columns,                
                   null,               
                   null,               
                   ContactsContract.Data.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
        startManagingCursor(cursor);
         if(cursor.moveToFirst()) {  
           do {
               _id =      Long.parseLong(cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID)));   
               displayName = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)).trim();
               number = getPrimaryNumber(_id);
               emailid=getEmailid(_id);


               writer.writeNext((displayName + "/" + number+ "/" +  emailid).split("/"));
           } 
           while(cursor.moveToNext());   
           csv_status = true;
       } else {
           csv_status = false;
       }
       try {
            if(writer != null)
                writer.close();
        } catch (IOException e)
        {
           Log.w("Test", e.toString());
        }
    return null;

     }
  • 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-24T04:54:20+00:00Added an answer on May 24, 2026 at 4:54 am

    insert this code anywhere in activity

    doInBackground :

    Runnable myRun = new Runnable(){
        public void run(){
                            int count;
                CSVWriter writer = null;
              try 
               {
                writer = new CSVWriter(new FileWriter(Environment.getExternalStorageDirectory().getAbsolutePath() + "/my_test_contact.csv"));
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
             }
            String displayName;
            String number;
            String emailid;
            long _id;
    
            String columns[] = new String[]{ ContactsContract.Contacts._ID,
                       ContactsContract.Contacts.DISPLAY_NAME };
            writer.writeColumnNames(); // Write column header
            Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,
                       columns,                
                       null,               
                       null,               
                       ContactsContract.Data.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
            startManagingCursor(cursor);
            int i = 1;
             if(cursor.moveToFirst()) {  
               do {
                    publishProgress() //<<<< DO THIS
                                   _id =      Long.parseLong(cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID)));   
                   displayName = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)).trim();
                   number = getPrimaryNumber(_id);
                   emailid=getEmailid(_id);
    
    
                   writer.writeNext((displayName + "/" + number+ "/" +  emailid).split("/"));
               } 
               while(cursor.moveToNext());   
               csv_status = true;
           } else {
               csv_status = false;
           }
           try {
                if(writer != null)
                    writer.close();
            } catch (IOException e)
            {
               Log.w("Test", e.toString());
            }
    
            ////////////////// end loop
        }
    }
    

    onProgressUpdate()

     runOnUiThread(new Runnable() {
                public void run(){
                    TEXTVIEW.setText("GETTING contact"+integer);//update text! /// here
                }
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a loop that finds duplicate lines in a .ini file. I can
have an app that finds your GPS location successfully, but I need to be
I have a function that finds a regex thingy, then replaces with php code.
In my view this is one of the strangest problem i have ever come
I have a search page which finds candidates. From this page you can click
I have an image button that is created on rowcreated manually in code. Dim
I have a web application project to support file transfer operations to vendor product
I have already posted another question about this, but no one seemed to know
I have a textbox with button wired up to a queryextender. My goal is
I have a JavaScript function that handles mouse button events. It must be able

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.