自己做出来了 把sqlite 文件转成string,然后用web service上传string. private void uploadFile()
{
try
{
FileInputStream fis = new FileInputStream(srcPath);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[98192];
int count = 0;
while ((count = fis.read(buffer)) >= 0)
{
baos.write(buffer, 0, count);
}
String image = new String(Base64.encode(baos.toByteArray()));
fis.close();
SoapObject request = new SoapObject(LoginUI.NAMESPACE, LoginUI.METHOD_NAME2);
request.addProperty("image", image);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.bodyOut = request;
HttpTransportSE ht = new HttpTransportSE(LoginUI.URL);
ht.call(LoginUI.NAMESPACE+LoginUI.METHOD_NAME2, envelope);
if (envelope.getResponse() != null)
{
org.ksoap2.serialization.SoapPrimitive soapPrimitive = (SoapPrimitive) envelope
.getResponse();
boolean result = Boolean.parseBoolean(soapPrimitive.toString());
if (result)
Toast.makeText(this, "Synchronize Successful.", Toast.LENGTH_LONG).show();
else
Toast.makeText(this, "Synchronize Fail.", Toast.LENGTH_LONG).show();
}
}
catch (Exception e)
{
Log.d("updateImage_exception", String.valueOf(e));
}
}server 端用VS2005建的web service,读取string 再回转成sqlite file 就可以了
public bool UploadFile (string image){
byte[]b =System.Convert.FromBase64String(image);
FileStream f=new FileStream(C:\\msir.db,FileMode.Create);
f.Write(m,0,m.Length);
return ture;
}
{
try
{
FileInputStream fis = new FileInputStream(srcPath);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[98192];
int count = 0;
while ((count = fis.read(buffer)) >= 0)
{
baos.write(buffer, 0, count);
}
String image = new String(Base64.encode(baos.toByteArray()));
fis.close();
SoapObject request = new SoapObject(LoginUI.NAMESPACE, LoginUI.METHOD_NAME2);
request.addProperty("image", image);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.bodyOut = request;
HttpTransportSE ht = new HttpTransportSE(LoginUI.URL);
ht.call(LoginUI.NAMESPACE+LoginUI.METHOD_NAME2, envelope);
if (envelope.getResponse() != null)
{
org.ksoap2.serialization.SoapPrimitive soapPrimitive = (SoapPrimitive) envelope
.getResponse();
boolean result = Boolean.parseBoolean(soapPrimitive.toString());
if (result)
Toast.makeText(this, "Synchronize Successful.", Toast.LENGTH_LONG).show();
else
Toast.makeText(this, "Synchronize Fail.", Toast.LENGTH_LONG).show();
}
}
catch (Exception e)
{
Log.d("updateImage_exception", String.valueOf(e));
}
}server 端用VS2005建的web service,读取string 再回转成sqlite file 就可以了
public bool UploadFile (string image){
byte[]b =System.Convert.FromBase64String(image);
FileStream f=new FileStream(C:\\msir.db,FileMode.Create);
f.Write(m,0,m.Length);
return ture;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货