【发布时间】:2014-07-16 06:09:58
【问题描述】:
我有一个代码来获取收件箱并在 ListAdapter 中显示,现在我想将收件箱数据保存到我想与服务器通信的 xml 文件中,将 xml 文件准确发送到服务器。怎么样?
这是我的代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
public void onClick(View arg0) {
startActivity(new Intent(MainActivity.this, ListAdapter.class));
}
List<SMSData> smsList2 = new ArrayList<SMSData>();
Uri outuri = Uri.parse("content://sms/sent");
Cursor outc = getContentResolver()
.query(outuri, null, null, null, null);
startManagingCursor(outc);
// Read the sms data and store it in the list
if (outc.moveToFirst()) {
for (int i = 0; i < outc.getCount(); i++) {
SMSData sms = new SMSData();
sms.setBody(outc.getString(outc.getColumnIndexOrThrow("body"))
.toString());
sms.setNumber(outc.getString(
outc.getColumnIndexOrThrow("address")).toString());
smsList2.add(sms);
outc.moveToNext();
}
}
outc.close();
// Set smsList in the ListAdapter
setListAdapter(new ListAdapter2(this, smsList2));
}
你能帮帮我吗?
【问题讨论】:
-
你想用 XML 做什么。只是为了保存数据?还是为了与服务器通信?
-
我想将数据保存在xml文件中并与服务器通信,将xml文件准确发送到服务器