0
我在android中创建了一个注册页面,其中包含一些名称文本框和一个上传按钮(我用来从图库中获取图像)并且必须将其存储在mysql中。如何使用webservice和axis2在android数据库中存储图像?
我GOOGLE了它,我有一些代码,他们正在使用PHP,但我没有使用PHP。 请提供一些有用的链接或代码。 如何使用Web服务将图像存储到mysql中?
我在android中创建了一个注册页面,其中包含一些名称文本框和一个上传按钮(我用来从图库中获取图像)并且必须将其存储在mysql中。如何使用webservice和axis2在android数据库中存储图像?
我GOOGLE了它,我有一些代码,他们正在使用PHP,但我没有使用PHP。 请提供一些有用的链接或代码。 如何使用Web服务将图像存储到mysql中?
使用此:
public void insertImg(int id , Bitmap img) {
byte[] data = getBitmapAsByteArray(img); // this is a function
insertStatement_logo.bindLong(1, id);
insertStatement_logo.bindBlob(2, data);
insertStatement_logo.executeInsert();
insertStatement_logo.clearBindings() ;
}
public static byte[] getBitmapAsByteArray(Bitmap bitmap) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.PNG, 0, outputStream);
return outputStream.toByteArray();
}
,并检索:
public Bitmap getImage(int i){
String qu = "select img from table where feedid=" + i ;
Cursor cur = db.rawQuery(qu, null);
if (cur.moveToFirst()){
byte[] imgByte = cur.getBlob(0);
cur.close();
return BitmapFactory.decodeByteArray(imgByte, 0, imgByte.length);
}
if (cur != null && !cur.isClosed()) {
cur.close();
}
return null ;
}
@Mallikarjun Hampannavar你用过吗? –
K我在哪里必须使用这些方法?我有一个Web服务类和活动类(android)。一旦我从图库上传图像,然后我必须通过网络服务将该图像存储到mysql数据库。请确认 –
成功将图像上传到web服务后,您可以使用这些方法。 –