摘要:
// Context.CONTEXT_IGNORE_SECURITY 忽略安全检测 //getContext().createPackageContext 创建其它应该程序的上下文对象 Context otherContext= getContext().createPackageContext("cn.itcast.preferences", Context.CONTEXT_IGNORE_SECURITY); SharedPreferences prefence= otherContext.getSharedPreferences("itcast", 阅读全文
posted @ 2012-05-17 21:22
左正
阅读(374)
评论(0)
推荐(0)
摘要:
如果要打开存放在/data/data/<package name>/files目录应用私有的文件,可以使用Activity提供openFileInput()方法。FileInputStream inStream = this.getContext().openFileInput("itcast.txt");Log.i("FileTest", readInStream(inStream));readInStream()的方法请看本页下面备注。或者直接使用文件的绝对路径:File file = new File("/data/data/ 阅读全文
posted @ 2012-05-17 20:50
左正
阅读(1280)
评论(0)
推荐(0)
摘要:
很多时候我们的软件需要对处理后的数据进行存储或再次访问。Android为数据存储提供了如下几种方式:文件SharedPreferences(参数)SQLite数据库内容提供者(Content provider)网络首先给大家介绍使用文件如何对数据进行存储,Activity提供了openFileOutput()方法可以用于把数据输出到文件中,具体的实现过程与在J2SE环境中保存数据到文件中是一样的。public class FileActivity extends Activity { @Override public void onCreate(Bundle savedInstanceStat 阅读全文
posted @ 2012-05-17 20:48
左正
阅读(337)
评论(0)
推荐(0)

浙公网安备 33010602011771号