• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 






花瓣15度

 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理

2013年4月8日

Android中SharedPreferences出现NullPointerException的解决办法【转】
摘要: 这几天写Service组件的时候,莫名其妙老出现NullPointerException异常,主要经过是这样的:在Activity中创建Preferences文件,然后在Service中使用这个文件,出错的源代码如下:1 import android.app.Service;2 import android.content.Intent;3 import android.content.SharedPreferences;4 import android.content.SharedPreferences.Editor;5 import android.os.IBinder;6 import 阅读全文
posted @ 2013-04-08 14:16 花瓣15度 阅读(374) 评论(0) 推荐(0)
 
android用SharedPreferences保存登录账户密码[转]
摘要: 首先介绍的是SharedPreferences,它是Android提供用来存储一些简单的配置信息的一种机制,例如,一些默认欢迎语、登录的用户名和密码等。其以键值对的方式存储,使得我们可以很方便的读取和存入,下面看一个演示的例子。 引用package us.imnet.iceskysl.db; import Android.app.Activity; import Android.content.SharedPreferences; import Android.os.Bundle; import Android.widget.EditText; public class DBSharedP.. 阅读全文
posted @ 2013-04-08 12:13 花瓣15度 阅读(310) 评论(0) 推荐(0)