0
我有一個JSONObject,我已經轉換爲一個JSON數組,然後進一步解析它的單獨的字符串。我已經連接這些以形成一個新的字符串。這是我用過的代碼。串聯期間插入多個?
for(int n = 0; n<newtrs_array.length();n++){
JSONObject object = newtrs_array.getJSONObject(n);
String newcompanyid = object.getString("companyid");
String newusername = object.getString("username");
String newdate = object.getString("date");
String newClientId = object.getString("clientid");
String newprojectId = object.getString("projectid");
String newniv1 = object.getString("niv1");
String newniv2 = object.getString("niv2");
String newworktypeid = object.getString("worktypeid");
String newtimetypeid = object.getString("timetypeid");
String newhours = object.getString("hours");
String newcomment = object.getString("comment");
String newprivatecomment = object.getString("privatecomment");
String newopen = object.getString("open");
String newreportid = object.getString("reportid");
newtrsArray += newcompanyid+"#"+newusername+"#"+newdate+"#"
+newClientId+"#"+newprojectId
+"#"+newniv1+"#"+newniv2+"#"+newworktypeid
+"#"+newtimetypeid+"#"+newhours+"#"+newcomment
+"#"+newprivatecomment+"#"+newopen+"#"+newreportid;
}
}
這是用於分割newtrsarray
for(int n=0; n<split_frombufferedValue.length; n++){
if(split_frombufferedValue[n] != null){
try{
//Log.i(TAG, "***********%%%%%%%%%"+split_frombufferedValue[1]);
newtrsArray = split_frombufferedValue[0].toString();
newschemaArray = split_frombufferedValue[1].toString();
Log.i(TAG, "************* "+newschemaArray);
newdeletedtrsArray = split_frombufferedValue[2].toString();
String newcreatedtrs_array = split_frombufferedValue[3].toString();
String newsync_reponse = split_frombufferedValue[4].toString();
String newmodtrs_array = split_frombufferedValue[5].toString();
} catch(Exception e){
e.printStackTrace();
}
}
}
split_newtrsArray = newtrsArray.split("#");
split_newdeletedtrsArray = newdeletedtrsArray.split("@@@@");
split_newschemaArray = newschemaArray.split("%%%%");
Log.i(TAG, "############# "+split_newtrsArray[0]+" -length "+split_newtrsArray.length);
}
我的問題是,代碼:newtrsarray爲約4000chars或更多的大小。這導致「#」被插入兩次或甚至三次。如下所示
&&--Second activty:HTTPClient--**(824): !!!!!------UTB17#DA#2011-10-10#1000#363636#10##105#30#5###no#30667UTB17#DA#2011-09-12#1000#363636#10##100##6##Not Available#yes#31659UTB17#DA#2011-09-13#1000#363636#10##100##2###yes#31665
我該如何解決此問題。這些值必須連接到一個字符串,然後在另一個函數中分割。這些必須被插入到數據庫中。希望我能夠清楚地解釋我的問題。
乾杯!