android下保存图片到mySQL_android将图片保存进数据库

本文提供了一个详细的Android将图片转换为Base64字符串并存储到数据库的教程。通过AssetManager读取图片,使用BitmapFactory解码,然后进行Base64编码。还展示了如何将Base64字符串还原为Bitmap显示。最后讨论了Base64编码后的大小变化,并提供了Demo下载链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近有朋友项目需要保存图片到本地数据库,问我怎么做,刚好我之前接触过,其实就是简单的base64编码转换,下面介绍超详细超简单demo:

首先放图,no图no bb:

7224786ae50a

效果图.png

第一步:创建工程,然后更改main.xml样式

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

tools:context=".MainActivity">

android:id="@+id/ivShow"

android:layout_width="match_parent"

android:layout_height="200dp" />

android:layout_width="match_parent"

android:layout_height="200dp">

android:id="@+id/tvCode"

android:layout_width="match_parent"

android:layout_height="wrap_content" />

android:id="@+id/transferToBase"

android:layout_width="match_parent"

android:layout_height="wrap_content

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值