導航:首頁 > 操作系統 > android上傳圖片資料庫中

android上傳圖片資料庫中

發布時間:2022-12-29 22:49:06

android圖片存取資料庫

1、存圖片路徑
2、存圖片二進制(sqllite blob的數據類型)
3、存圖片Uri

② android 怎麼上傳bitmap 到資料庫

andorid推薦的是如果數據在20-50k可以存放到資料庫,否則資料庫存路徑。

③ 使用android上傳圖片到伺服器,並且把圖片保存到伺服器的某個文件夾

有兩種方法,第一,把你的圖片轉成位元組流,然後用post方法把位元組流傳到服務端,然後服務端接收到位元組流之後,開啟一個線程把它重新壓縮成圖片,保存在某個文件夾下面。
第二,開啟一個線程,用socket直接把圖片放到stream中傳到服務端,服務端接收後保存到文件夾下。

④ android怎麼將圖片傳送到伺服器,然後將圖片保存在mysql資料庫中

一般資料庫中是不保存圖片的,保存的是圖片存放路徑,圖片放到文件夾中,如果放到資料庫中資料庫會很大,影響讀取速度。
如果想放就把欄位定義為如:`img` longblob;
然後就可以讀取文件流 存儲到資料庫中了就可以了

⑤ android 如何獲取保存的圖片的地址 並存到資料庫中

安卓中如何獲取保存的圖片uri 並保存到sqlite資料庫中
有如下兩種方法,僅供參考
方法一:java代碼

public void saveIcon(Bitmap icon) {
if (icon == null) {
return;
}
// 最終圖標要保存到瀏覽器的內部資料庫中,系統程序均保存為SQLite格式,Browser也不例外,因為圖片是二進制的所以使用位元組數組存儲資料庫的
// BLOB類型
final ByteArrayOutputStream os = new ByteArrayOutputStream();
// 將Bitmap壓縮成PNG編碼,質量為100%存儲
icon.compress(Bitmap.CompressFormat.PNG, 100, os);
// 構造SQLite的Content對象,這里也可以使用
raw ContentValues values = new ContentValues();
// 寫入資料庫的
Browser.BookmarkColumns.TOUCH_ICON欄位 values.put(Browser.BookmarkColumns.TOUCH_ICON, os.toByteArray());
DBUtil.update(....);
//調用更新或者插入到資料庫的方法
}
}

方法二:如果數據表入口時一個content:URIJava代碼

import android.provider.MediaStore.Images.Media;
import android.content.ContentValues;
import java.io.OutputStream;
// Save the name and description of an image in a ContentValues map.
ContentValues values = new ContentValues(3);
values.put(Media.DISPLAY_NAME, "road_trip_1");
values.put(Media.DESCRIPTION, "Day 1, trip to Los Angeles");
values.put(Media.MIME_TYPE, "image/jpeg");
// Add a new record without the bitmap, but with the values just set.
// insert() returns the URI of the new record.
Uri uri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);
// Now get a handle to the file for that record, and save the data into it.
// Here, sourceBitmap is a Bitmap object representing the file to save to the database.
try {
OutputStream outStream = getContentResolver().openOutputStream(uri);
sourceBitmap.compress(Bitmap.CompressFormat.JPEG, 50, outStream);
outStream.close();
} catch (Exception e) {
Log.e(TAG, "exception while writing image", e);
}
原文請看http://www.bafenbaosoft.com/post/48.html

閱讀全文

與android上傳圖片資料庫中相關的資料

熱點內容
蘋果平板如何開啟隱私單個app 瀏覽:700
空調壓縮機一開就停止 瀏覽:524
如何下載虎牙app 瀏覽:847
日語年號的演算法 瀏覽:953
dev裡面的編譯日誌咋調出來 瀏覽:298
php函數引用返回 瀏覽:816
文件夾和文件夾的創建 瀏覽:259
香港加密貨幣牌照 瀏覽:838
程序員鼓勵自己的代碼 瀏覽:393
計算機網路原理pdf 瀏覽:752
吃雞國際體驗服為什麼伺服器繁忙 瀏覽:94
php中sleep 瀏覽:490
vr怎麼看視頻演算法 瀏覽:86
手機app如何申報個人所得稅零申報 瀏覽:692
如何截獲手機app連接的ip 瀏覽:331
冰箱壓縮機是否需要電容 瀏覽:346
python列表每一行數據求和 瀏覽:274
自己有一台伺服器可以玩什麼 瀏覽:656
社會學波普諾pdf 瀏覽:584
解壓做食物的小視頻 瀏覽:758