2013-07-01 28 views
0

如何通過Web服務執行SQL查詢以在android平臺上的服務器數據庫中插入數據。並且如果您有要在服務器數據庫上插入圖像,那麼它如何使用該查詢字符串。SQL通過ksoap WebService在android中

StackOverFlow中的新功能。對不起英文。

if (mediaFile != null) { 
    Bitmap bm = BitmapFactory.decodeFile(mediaFile.getAbsolutePath()); 
    ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
    bm.compress(Bitmap.CompressFormat.PNG, 100, baos); 
    byte[] b = baos.toByteArray(); 
    //encodedImage = Base64.encodeToString(b, Base64.DEFAULT); 
} else{ 
    Toast.makeText(this, "Capture An Asset Image.", Toast.LENGTH_LONG) .show(); 
+0

可以Base64編碼的圖像 – DevZer0

+0

如果(媒體文件!= NULL){ \t \t \t位圖BM = BitmapFactory.decodeFile(mediaFile.getAbsolutePath()); \t \t \t ByteArrayOutputStream baos = new ByteArrayOutputStream(); \t \t \t bm.compress(Bitmap.CompressFormat.PNG,100,baos); \t \t \t byte [] b = baos.toByteArray(); \t \t \t // encodedImage = Base64.encodeToString(b,Base64.DEFAULT); \t \t}否則{ \t \t \t Toast.makeText(這一點, 「捕獲資產圖像。」,Toast.LENGTH_LONG) \t \t \t \t \t .show(); –

+0

當我在Base64中編碼byteArray時,出現異常---內存不足異常。 –

回答

1

如果你得到了內存問題的錯誤,那麼這將幫助你。

public Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) { 
    int width = bm.getWidth(); 
    int height = bm.getHeight(); 
    float scaleWidth = ((float) newWidth)/width; 
    float scaleHeight = ((float) newHeight)/height; 
    // CREATE A MATRIX FOR THE MANIPULATION 
    Matrix matrix = new Matrix(); 
    // RESIZE THE BIT MAP 
    matrix.postScale(scaleWidth, scaleHeight); 

    // "RECREATE" THE NEW BITMAP 
    Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, 
      matrix, false); 
    return resizedBitmap; 
}