我有我的sqlite數據庫base64字符串,我發送所有這些記錄到服務器。我面臨的問題是,當我試圖將這些base64字符串發送到服務器時,它只發送第一條原始記錄,然後發送其他行的空值。我調試了我的代碼,我發現第一次如果條件滿足,第二行就會失敗。我該如何解決這個問題?如何從sqlite獲取所有圖像base64字符串?
class async_SaveImage extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
SoapObject request = new SoapObject(namespacegetlistdata, method_name__image);
cursorImage = db.rawQuery("select * from FieldTestDataFinal Where isSend ='N'", null);
/*for(int i=0; i<cursor.getCount(); i++)
{*/
int k = 0;
try {
if (cursorImage.moveToFirst()) {
/*while (cursor.moveToNext())*/
do {
JSONArray arr = new JSONArray();
JSONObject jsonObject = new JSONObject();
//request.properties.clear();
if (k == 0) {
request.addProperty("fileByte1", cursorImage.getString(cursorImage.getColumnIndex("METER_IMAGE1")));//add the parameters
request.addProperty("fileName1", cursorImage.getString(cursorImage.getColumnIndex("fileName1")));//add the parameters
request.addProperty("fileByte2", cursorImage.getString(cursorImage.getColumnIndex("METER_IMAGE2")));//add the parameters
request.addProperty("fileName2", cursorImage.getString(cursorImage.getColumnIndex("fileName2")));//add the parameters
request.addProperty("fileByte3", cursorImage.getString(cursorImage.getColumnIndex("METER_IMAGE3")));//add the parameters
request.addProperty("fileName3", cursorImage.getString(cursorImage.getColumnIndex("fileName3")));//add the parameters
request.addProperty("fileByte4", cursorImage.getString(cursorImage.getColumnIndex("METER_IMAGE4")));//add the parameters
request.addProperty("fileName4", cursorImage.getString(cursorImage.getColumnIndex("fileName4")));//add the parameters
request.addProperty("fileByte5", cursorImage.getString(cursorImage.getColumnIndex("METER_IMAGE5")));//add the parameters
request.addProperty("fileName5", cursorImage.getString(cursorImage.getColumnIndex("fileName5")));//add the parameters
request.addProperty("fileByte6", cursorImage.getString(cursorImage.getColumnIndex("SIGNATURE_CONSUMER")));//add the parameters
request.addProperty("fileName6", cursorImage.getString(cursorImage.getColumnIndex("fileName6")));//add the parameters
// request.addProperty("fileName", "123.jpeg");//add the parametershe parameters
} else {
request.setProperty(0, cursorImage.getString(cursorImage.getColumnIndex("METER_IMAGE1")));//add the parameters
request.setProperty(1, cursorImage.getString(cursorImage.getColumnIndex("fileName1")));//add the parameters
request.setProperty(0, cursorImage.getString(cursorImage.getColumnIndex("METER_IMAGE2")));//add the parameters
request.setProperty(1, cursorImage.getString(cursorImage.getColumnIndex("fileName2")));//add the parameters
request.setProperty(0, cursorImage.getString(cursorImage.getColumnIndex("METER_IMAGE3")));//add the parameters
request.setProperty(1, cursorImage.getString(cursorImage.getColumnIndex("fileName3")));//add the parameters
request.setProperty(0, cursorImage.getString(cursorImage.getColumnIndex("METER_IMAGE4")));//add the parameters
request.setProperty(1, cursorImage.getString(cursorImage.getColumnIndex("fileName4")));//add the parameters
request.setProperty(0, cursorImage.getString(cursorImage.getColumnIndex("METER_IMAGE5")));//add the parameters
request.setProperty(1, cursorImage.getString(cursorImage.getColumnIndex("fileName5")));//add the parameters
request.setProperty(0, cursorImage.getString(cursorImage.getColumnIndex("SIGNATURE_CONSUMER")));//add the parameters
request.setProperty(1, cursorImage.getString(cursorImage.getColumnIndex("fileName6")));//add the parameters
}
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);//set soap version
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
try {
HttpTransportSE androidHttpTransport = new HttpTransportSE(url_getlistdata);
androidHttpTransport.call(soap_action_uploadImage, envelope); // this is the actual part that will call the webservice
//SoapPrimitive prim = (SoapPrimitive) envelope.getResponse(); // Get the SoapResult from the envelope body.
SoapObject response = (SoapObject) envelope.bodyIn;
//hideDialog();
} catch (Exception e) {
e.printStackTrace();
Log.d("myError -", String.valueOf(e));
}
k++;
} while (cursorImage.moveToNext());
/* object = new JSONObject();
object.put("data", arr);*/
}
cursorImage.close();
} catch (Exception e) {
}
// }
return resultSaveAllData;
}
@Override
protected void onPostExecute(String result1) {
try {
} catch (Exception e) {
}
super.onPostExecute(result1);
}
}
雅我更換財產中的其他條件,但對於第一次檢查,如果條件但第二次爲什麼別的檢查?我做錯了,否則這就是爲什麼它檢查其他。 –
那麼我必須改變什麼? –
我的要求是假設我有三個記錄在我的sqlite,但它只發送第一個記錄到服務器。爲什麼不發送所有記錄? –