最近有朋友项目需要保存图片到本地数据库,问我怎么做,刚好我之前接触过,其实就是简单的base64编码转换,下面介绍超详细超简单demo:
首先放图,no图no bb:
效果图.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