内存卡的数据保存与读取-创新互联

,内存卡

成都创新互联公司网站建设公司,提供网站制作、成都做网站,网页设计,建网站,PHP网站建设等专业做网站服务;可快速的进行网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,是专业的做网站团队,希望更多企业前来合作!

   2.1数据保存

File file=newFile(Environment.getExternalStorageDirectory(), name);

                                                 try{

                                                           FileOutputStream   fos=newFileOutputStream(file);

                                                           fos.write(content.getBytes());

                                                           fos.close();

                                                              Toast.makeText(getApplicationContext(), "保存成功", 200).show();

                                                 }  catch(Exception e) {

                                                              Toast.makeText(getApplicationContext(), "保存失败", 200).show();

                                                           e.printStackTrace();

                                                 }

            

2.2数据读取

File file=newFile(Environment.getExternalStorageDirectory(), name);

                                                 try{

                                                           FileOutputStream   fos=newFileOutputStream(file);

                                                           fos.write(content.getBytes());

                                                           fos.close();

                                                              Toast.makeText(getApplicationContext(), "保存成功", 200).show();

                                                 }  catch(Exception e) {

                                                              Toast.makeText(getApplicationContext(), "保存失败", 200).show();

                                                           e.printStackTrace();

                                                 }

  3,sharedprefrence (****)

      btn_ok.setOnClickListener(newOnClickListener() {

                      

                             @Override

                             publicvoidonClick(View v) {

                                

                                                 String  user = et_user.getText().toString().trim();

                                                 String  pwd = et_pwd.getText().toString().trim();

                                                 if(user.isEmpty()||pwd.isEmpty()){

                                                           Toast.makeText(getApplicationContext(), "不能为空", 200).show();

                                                           //获取编辑器

                                                    Editor edit = sp.edit();

                                                                //保存数据

                                                    edit.putString("name", user);

                                                    edit.putString("pwd", pwd);

                                                    //提交保存

                                                    edit.commit();  

                                                 }                                

                             }

                   });


网页标题:内存卡的数据保存与读取-创新互联
文章路径:http://bzwzjz.com/article/ioepe.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都网站建设公司 成都网站建设 网站制作 外贸网站设计方案 企业网站建设 高端网站设计 企业网站设计 成都商城网站制作 攀枝花网站设计 定制网站制作 成都做网站建设公司 成都网站设计 高端网站设计推广 成都网站设计 营销型网站建设 成都企业网站建设 成都网站设计 泸州网站建设 网站建设改版 成都响应式网站建设公司 梓潼网站设计 温江网站设计