第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何將圖像作為BLOB存儲在Sqlitt中&如何檢索?

如何將圖像作為BLOB存儲在Sqlitt中&如何檢索?

BIG陽 2019-06-21 15:07:28
如何將圖像作為BLOB存儲在Sqlitt中&如何檢索?我想把一個圖片(從url)存儲到sqite數(shù)據(jù)庫中。為此,我使用:db = new DataBase(getApplicationContext());URL url = new URL("http://sree.cc/wp-content/uploads/schogini_team.png");URLConnection ucon = url.openConnection();InputStream is = ucon.getInputStream();BufferedInputStream bis = new BufferedInputStream(is,128);ByteArrayBuffer barb= new ByteArrayBuffer(128);int current = 0;while ((current = bis.read()) != -1) {    barb.append((byte) current);}ContentValues filedata= new ContentValues();filedata.put(DataBase.IMG_SRC,barb.toByteArray());db.insert(DataBase.Table_Img, null, filedata);在Insert():public void insert(String tableImg, Object object,        ContentValues dataToInsert) {    // TODO Auto-generated method stub    String sql = "INSERT INTO "+tableImg+" ("+ID+","+IMG_SRC+") " +            "VALUES ('"+1+"','"+dataToInsert+"')";    db.execSQL(sql);}用于檢索圖像:Cursor cursor = db.selectDataToShow(DataBase.Table_Img, DataBase.IMG_SRC);byte[] imageByteArray=cursor.getBlob(cursor.getColumnIndex(DataBase.IMG_SRC));      cursor.close();ByteArrayInputStream imageStream = new ByteArrayInputStream(imageByteArray);Bitmap theImage = BitmapFactory.decodeStream(imageStream);System.out.println(">>>>>>>>>>>>>>>>>>>>>> "+theImage);所以我找到了null.在我的數(shù)據(jù)庫中,圖像的值存儲為:Image=[B@43e5ac48]
查看完整描述

3 回答

  • 3 回答
  • 0 關注
  • 642 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號