Call logs restore in android -


i creating application in android call logs backup , restore using csv file.backup created while restoring call logs not restored csv.here code writing backup

 while((row = csvreader.readnext()) != null)                      {                     restorecalllogs(row[0],row[1],row[2],row[3],row[4]);                      }    public  void restorecalllogs(string name,string number,string date,string type,string duration){         contentvalues values = new contentvalues();         values.put(calllog.calls.number, number);         values.put(calllog.calls.date, date);         values.put(calllog.calls.duration,duration);         values.put(calllog.calls.type, type);          if(name!="unknown")          values.put(calllog.calls.cached_name, name);         getcontentresolver().insert(calllog.calls.content_uri, values);     } 

you have try-catch block hiding exception generated here:

restorecalllogs(row[0],row[1],row[2],row[3],row[4]); 

you should not use try-catch without understanding does.

to fix:

string[] row; while((line = csvreader.readnext()) != null){     row = line.split(",");     restorecalllogs(row[0],row[1],row[2],row[3],row[4]); } 

please read documentation .split(). need work deal commas , other non-alphanumeric characters inside strings of contact record. assuming csv contains 5 columns. can guarantee that?

finally, please use accepted conventions naming identifiers in java. using capital letter start variable name makes code hard read.

[edit]

i don't know how code compiles. please show declarations row , csvreader.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -