文章分类 -  Android Shared Preferences

摘要:使用SharedPerferences 保存app使用次数:package com.example.androidshareperferencesdemo;import android.os.Bundle;import android.app.Activity;import android.content.SharedPreferences;import android.content.SharedPreferences.Editor;import android.view.Menu;import android.widget.Toast;public class MainActivity e 阅读全文
posted @ 2013-11-13 00:30 MMLoveMeMM 阅读(414) 评论(0) 推荐(0) 编辑
摘要:Shareperferences数据保存在物理磁盘的/data/data/package_name/shared_prefs目录下package com.example.androidshareperferences;import android.os.Bundle;import android.app.Activity;import android.content.SharedPreferences;import android.view.Menu;import android.view.View;import android.view.View.OnClickListener;import 阅读全文
posted @ 2013-11-13 00:19 MMLoveMeMM 阅读(383) 评论(0) 推荐(0) 编辑
摘要:先看Application Fundamentals上的一段话:Android calls onSaveInstanceState() before the activity becomes vulnerable to being destroyed by the system, but does not bother calling it when the instance is actually being destroyed by a user action (such as pressing the BACK key)从这句话可以知道,当某个activity变得“容易”被系统销毁时,该 阅读全文
posted @ 2013-10-15 11:00 MMLoveMeMM 阅读(268) 评论(0) 推荐(0) 编辑
摘要:本文介绍Android中关于Activity的两个神秘方法:onSaveInstanceState() 和 onRestoreInstanceState(),并且在介绍这两个方法之后,再分别来实现使用InstanceState保存和恢复数据功能、Android实现屏幕旋转异步下载效果这样两个示例。 首先来介绍onSaveInstanceState() 和 onRestoreInstanceState()。关于这两个方法,一些朋友可能在Android开发过程中很少用到,但在有时候掌握其用法会帮我们起到比较好的效果。尤其是在应用程序在不知道的情况下退出后,如何实现其数据保存的功能。先来让我们看下. 阅读全文
posted @ 2013-10-10 12:18 MMLoveMeMM 阅读(164) 评论(0) 推荐(0) 编辑
摘要:Shared Preferences类似于我们常用的ini 文件,用来保存应用程序的一些属性设置,在 Android平台常用于存储比较简单的参数设置。例如,可以通过它保存上一次用户所做的修改或者自定义参数设定,当再次启动程序后依然保持原有的设置。通过 getPreferences()方法来获得Preferences对象,通过 "SharedPreferences.Editor editor = uiState.edit();" 取得编辑对象,然后通过"edit.put....()"方法添加数据,最后通过commit()方法保存这些数据,如果不需要与其它模 阅读全文
posted @ 2013-10-10 00:31 MMLoveMeMM 阅读(191) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示