如何在sqlite中插入与blob相同的表的两个URL

时间:2012-11-22 04:07:48

标签: android sqlite

我在桌子上有两张图片。现在我必须将它们作为blob存储在SQLite中。但我很难找到一种方法来获得它在两个URL的情况下。如果它是一个我可以解决它。任何人都可以建议我如何解决这个问题吗?

我正在尝试的代码是:

private void callInsertion(String bid, String bbookId,String bname, String image1, String image2, String bdesc) throws IOException {
// TODO Auto-generated method stub

     DefaultHttpClient mHttpClient = new DefaultHttpClient();
     HttpGet mHttpGet1 = new HttpGet(image1);
     HttpGet mHttpGet2 = new HttpGet(image2);
     HttpResponse mHttpResponse = mHttpClient.execute(mHttpGet1,mHttpGet2);

     if (mHttpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) 
     {
         HttpEntity entity = mHttpResponse.getEntity();
         if ( entity != null) 
         {
             insertData(bid,bbookId,bname,EntityUtils.toByteArray(entity),EntityUtils.toByteArray(entity),bdesc);
         }
     }
}

但我在客户端执行时遇到错误。

1 个答案:

答案 0 :(得分:1)

尝试这样做!!

         private void callInsertion(String bid, String bbookId,String bname, String image1, String image2, String bdesc) throws IOException {
            // TODO Auto-generated method stub

        byte[] FirstImage = null;
        byte[] SecondImage = null;
        DefaultHttpClient mHttpClient1 = new DefaultHttpClient();
        DefaultHttpClient mHttpClient2 = new DefaultHttpClient();
        HttpGet mHttpGet1 = new HttpGet(image1);
        HttpGet mHttpGet2 = new HttpGet(image2);
        HttpResponse mHttpResponse1 = mHttpClient1.execute(mHttpGet1);
        HttpResponse mHttpResponse2 = mHttpClient2.execute(mHttpGet2);
        Log.i("calling112221","______________");
        if (mHttpResponse1.getStatusLine().getStatusCode() == HttpStatus.SC_OK) 
        {
               HttpEntity entity1 = mHttpResponse1.getEntity();
               FirstImage = EntityUtils.toByteArray(entity1);
               Log.i("calling11111111","______________");
        }
        if (mHttpResponse2.getStatusLine().getStatusCode() == HttpStatus.SC_OK) 
        {
                HttpEntity entity2 = mHttpResponse2.getEntity();
                SecondImage = EntityUtils.toByteArray(entity2);
                Log.i("calling","______________");
        }

                    insertData(bid,bbookId,bname,FirstImage,SecondImage,bdesc);
        }