- 浏览: 238367 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
江恂泽:
楼主 这家伙会把data 拆分开来 转换成day year形 ...
JsonUtil -
mdsp25xhm:
为何没有列表查询功能?
myBatis DAO封装
public void disposeImage()
{
ByteArrayOutputStream outputStream = null;
try
{
SharedPreferences preferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Activity.MODE_PRIVATE);
Editor editor = preferences.edit();
outputStream = new ByteArrayOutputStream();
/*
* 读取和压缩图片资源 并将其保存在 ByteArrayOutputStream对象中
*/
BitmapFactory.decodeResource(getResources(), R.drawable.jt6).compress(CompressFormat.JPEG, 50, outputStream);
String imgBase64 = new String(Base64.encode(outputStream.toByteArray(), Base64.DEFAULT));
editor.putString("image", imgBase64);
editor.commit();
readImage();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
if (null != outputStream)
{
try
{
outputStream.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
public void readImage()
{
ByteArrayInputStream inputStream = null;
try
{
SharedPreferences preferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Activity.MODE_PRIVATE);
String imgbase64 = preferences.getString("image", "");
byte[] imgbyte = Base64.decode(imgbase64.getBytes(), Base64.DEFAULT);
inputStream = new ByteArrayInputStream(imgbyte);
ImageView view = (ImageView) findViewById(R.id.preference_image);
view.setImageDrawable(Drawable.createFromStream(inputStream, "image"));
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
if (null != inputStream)
{
try
{
inputStream.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
{
ByteArrayOutputStream outputStream = null;
try
{
SharedPreferences preferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Activity.MODE_PRIVATE);
Editor editor = preferences.edit();
outputStream = new ByteArrayOutputStream();
/*
* 读取和压缩图片资源 并将其保存在 ByteArrayOutputStream对象中
*/
BitmapFactory.decodeResource(getResources(), R.drawable.jt6).compress(CompressFormat.JPEG, 50, outputStream);
String imgBase64 = new String(Base64.encode(outputStream.toByteArray(), Base64.DEFAULT));
editor.putString("image", imgBase64);
editor.commit();
readImage();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
if (null != outputStream)
{
try
{
outputStream.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
public void readImage()
{
ByteArrayInputStream inputStream = null;
try
{
SharedPreferences preferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Activity.MODE_PRIVATE);
String imgbase64 = preferences.getString("image", "");
byte[] imgbyte = Base64.decode(imgbase64.getBytes(), Base64.DEFAULT);
inputStream = new ByteArrayInputStream(imgbyte);
ImageView view = (ImageView) findViewById(R.id.preference_image);
view.setImageDrawable(Drawable.createFromStream(inputStream, "image"));
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
if (null != inputStream)
{
try
{
inputStream.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
发表评论
-
IMF简介-2
2013-07-09 17:56 855InputManager 由UI控件(View,TextVie ... -
IMF简介-1
2013-07-09 17:51 776Input Method Framework 目录 ... -
输入法 总结-3
2013-07-08 15:02 819public class MainActivity exten ... -
输入法 总结-4
2013-07-04 17:29 902public class InputActivity exte ... -
输入法 总结-3
2013-07-04 17:28 832public class InputApplication e ... -
输入法 总结-2
2013-07-04 17:23 740openwnn_pref_ja.xml <?xml v ... -
输入法 总结-2
2013-07-04 17:21 13openwnn_pref_ja.xml <?xml v ... -
输入法 总结-1
2013-07-04 17:19 766<application android ... -
Android快捷键
2013-03-15 14:39 774Home键(小房子键) 在 ... -
如何通过wifi调试android程序
2013-02-27 15:48 717android手机居然可以通过wifi进行程序的调试,太好了, ... -
Please ensure that adb is correctly located at 'D:\android-sdk-windows\platform-
2013-02-27 14:27 1610adt 出现ADB server didn't ACK, fa ... -
Android AsyncTask
2013-02-19 09:35 1064AsyncTask是抽象类,子类 ... -
Android ViewPager 左右滑动2-1
2013-01-29 10:12 1409public class PagerActivity exte ... -
Android ViewPager 左右滑动-3
2013-01-29 10:10 1066<?xml version="1.0" ... -
Android ViewPager 左右滑动-2
2013-01-29 10:10 1404/*** * 选中效果 */ pu ... -
Android ViewPager 左右滑动-1
2013-01-29 10:09 1337Store extends ActivityGroup imp ... -
Android 下载
2013-01-27 00:59 869下载apk程序代码 protected File downLo ... -
Android SDCard操作-3
2013-01-26 18:31 847public static Intent getVid ... -
Android SDCard操作-2
2013-01-26 18:30 1035/** * 判断该应用在手机中的安装情况 ... -
Android SDCard操作-1
2013-01-26 18:27 1000private static int INSTALLED = ...
相关推荐
android应用SharedPreferences_Demoandroid应用SharedPreferences_Demoandroid应用SharedPreferences_Demoandroid应用SharedPreferences_Demoandroid应用SharedPreferences_Demoandroid应用SharedPreferences_Demo...
DataStore 以异步、一致的事务方式存储数据,克服了 SharedPreferences(以下统称为SP)的 一些缺点。 DataStore 基于 Kotlin 协程和 Flow 实现,并且可以对 SP 数据进行迁移,旨在取代 SP 。 DataStore 提供了两种...
Android SharedPreferences应用 实现本地注册登陆 功能简单易懂(实例) http://blog.csdn.net/h1028962069/article/details/9129851 文章代码
Android使用SharedPreferences进行数据存储,缓存ID等数据
Android系统SharedPreferences进行的封装
利用SharedPreferences设置初始密码,并修改密码。详见http://blog.csdn.net/chenfengdejuanlian/article/details/46331031
android,SharedPreferences
Android SharedPreferences SP 工具类,存储临时数据用
android SharedPreferences 载入已记住的用户信息,类写的简单易懂,很清楚
使用SharedPreferences保存key-value对
android SharedPreferences记录你的登录信息
Simple Android SharedPreferences wrapper. Repository Add this in your root build.gradle file (not your module build.gradle file): allprojects { repositories { ... maven { url ...
在Android使用SharedPreferences实现自动登录
SharedPreferences用于简单的数据存储,是通过“name-value对”的机制存储数据,可以存储一些基本的数据类型包括:Boolean,string,float,long和integer类型。 数据是存储在XML文件中的。
SharedPreferences文件在不同应用之间数据共享
NULL 博文链接:https://2528.iteye.com/blog/1048725
主要为大家详细介绍了Android SharedPreferences实现记住密码和自动登录,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
简单的Android SharedPreferences封装
Fit 利用 SharedPreferences 存储对象
android学习SharedPreferences使用demo源代码