-1

I am new to android i am in need to read a contact details as contact name and phone number form csv file and store it into android phone by pro grammatically please help any one . thanks in advance

rajesh
  • 29
  • 2
  • 10

1 Answers1

-1

It's just a read and parse CSV file program that you need .

So you can do something like :

 //--- If your input stream  is `inpStrm` of the csv file :

    BufferedReader reader = new BufferedReader(new InputStreamReader(inpStrm));
    try {
        String line;
        while ((line = reader.readLine()) != null) {
             String[] RowData = line.split(",");
             date = RowData[0];
             value = RowData[1];
            // Now use "data" and "value" as you need to 
        }
    }
    catch (IOException ex) {
        // ex.printStackTrace();
    }
    finally {
        try {
            inpStrm.close();
        }
        catch (IOException e) {
            // e.printStackTrace();
        }
    }

Now contact name and phone number will be present in data and value. That's it i suppose .

The Dark Knight
  • 5,455
  • 11
  • 54
  • 95
  • the above code works to read from csv file and store into a variables.could please tell me about how to import these contacts into phone in android by programmatically .please give some idea – rajesh May 31 '13 at 13:33
  • @user2310115 : Look here for some ideas : http://stackoverflow.com/questions/3079365/android-retrieve-contact-name-from-phone-number?rq=1 – The Dark Knight May 31 '13 at 15:50
  • In this preferred link is used to retrieve a data from the phone .. I'm in need some idea about how to import the contacts to phone by programmatically – rajesh Jun 01 '13 at 04:51