安卓存储

--sharedPreferences
1.getSharedPreferences(name,flag);(其为接口只能通过context方法获得其实例)
2.读入数据 sjy.putXXX;
3.写入数据 SharePreferences.Eidtor 创建editor来写入   最后用editor.commit提交;
补:1.用createPackageContext(name,flag)创建其他包的context

--File
1.FileInputStream in=openFileInput(name);
2.FileOutputStream out=openFileOutput(name,mode);(可用printStream包装out)
拓展:读写SD卡 1.Environment.getExternalStorageState.equals(Environment.MEDIA_MOUNTED) 判断SD有无是否可读写
                                 2.fileStream可被包装。

--SQLite
1.SQLiteDatabase.getOrCreateDatabase(FIle or name,null); 创建Database
2.用execSQL执行DDL语句   用rawQuery执行可返回Cursor的SQL语句。
3.继承SQLiteOpenHelper类 实现onCreate方法中创建数据库  用其getReadableDatabase()和getWriteableDatebase();来更好的创建数据库
4.记得关闭dpHelper.close();
补:1.integer primary key autoincrement;
        2.创:create table sjy(_id  integer primary key autoincrement,name varchar(25),gender varchar(25))
           增 insert into sjy values(,,);
           删 delete from sjy where _id=1;
           查 selete * from sjy where ;
           改 update sjy set name='xxx' where _id=1;

            (SQL语句)   http://baike.baidu.com/view/3146511.htm
              (sqlite3)  http://developer.android.com/intl/zh-tw/tools/help/sqlite3.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值