简体   繁体   中英

how to use below response received from server and save in to database

我将联系人发送到服务器以检查其是否在服务器上注册,服务器返回此响应如何使用它并保存到数据库编号中,并根据编号结果正确与否7837580550,false,9780929022,true,9855772008,false,

Use a List of Map to the store the values and insert into database using it.

String[] arr=response.split(",");
List<Map<String,String>> list = new ArrayList();
for(int i = 0; i<arr.length; i+2){
String contactNo = arr[i];
String result = arr[i+1];
Map<String,String> m = new HashMap();
m.put(contactNo,result);
list.add(m);
}

As per my thinking you should get response in XMl format. I will be easy to handle and easy to manage the parsed output.

<Response>
  <MobileNo>7837580550</MobileNo>
  <Status>False</Status>
  <MobileNo>9780929022</MobileNo>
  <Status>True</Status>
  <MobileNo>9855772008</MobileNo>
  <Status>False</Status>
</Response>

While parsing you can store parsed information in different array. Rest you know how to get data from array and store in db.

Hope this will help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM