我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

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

,内存卡

成都创新互联公司网站建设公司,提供网站制作、成都做网站,网页设计,建网站,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://shouzuofang.com/article/ioepe.html

其他资讯