您好,下面是一种fileUpload
调用方法的方法,上传文件后我想删除该synchronized
对象,我这样做了。现在我必须通过调用fillRecipients()
方法重新加载页面,它的作用是列出数据库中的所有信息并显示在listView
. 由于我使用了线程,它不允许我放入fillRecipeints
线程内,但我希望它位于下面的第 230 行 [下面注释为第 230 行] 这是我的Synchronize
方法:
public void synchronize(final String id){
dialog = ProgressDialog.show(ViewRecipients.this, "", "Uploading this file...", true);
new Thread(new Runnable() {
public void run() {
runOnUiThread(new Runnable() {
public void run() {
//uploading.setText("uploading started.....");
//dialog.show();
}
});
mDbHelper.open();
Cursor cData = mDbHelper.fetchRecipientInfo(id);
for(cData.moveToFirst();!cData.isAfterLast();cData.moveToNext()){
String id = cData.getString(cData.getColumnIndex("fld_recipient_id"));
String info = cData.getString(cData.getColumnIndex("fld_info"));
String latitude = cData.getString(cData.getColumnIndex("fld_latitude"));
String longitude = cData.getString(cData.getColumnIndex("fld_longitude"));
ArrayList<String> imagesArray = new ArrayList<String>();
for (int i = 1; i <= 4; i++) {
String image = cData.getString(cData.getColumnIndex("fld_image_url" + i));
if (image != null) {
imagesArray.add(image);
}
}
try {
serverResponseCode = uploadFile(imagesArray, info, latitude, longitude, id);
if (serverResponseCode==200){
mDbHelper.deleteRecipientRecId(id);
//Line NO 230 here i want to add fillRecipients() method
}
dialog.dismiss();
} catch (IOException e) {
e.printStackTrace();
dialog.dismiss();
}
}
cData.close();
mDbHelper.close();
if(serverResponseCode == 200){
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(ViewRecipients.this, "File Upload Complete.", Toast.LENGTH_SHORT).show();
}
});
}
}
}).start();
}
这是我的 fillRecipeints() 方法:
private void fillRecipients(){
mCursor = mDbHelper.fetchAllRecipientsInfo();
if (mCursor==null){
System.out.println("empty cursor");
}
else{
String [] from = new String[]{MunchaDbAdapter.FLD_RECIPIENT_ID};
int [] to = new int[]{R.id.text1};
SimpleCursorAdapter recipient = new SimpleCursorAdapter(this, R.layout.recipient_show, mCursor, from, to);
setListAdapter(recipient);
}
}
有谁能够帮我?