大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

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

,内存卡

成都创新互联公司网站建设公司,提供网站制作、成都做网站,网页设计,建网站,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://dzwzjz.com/article/ioepe.html
在线咨询
服务热线
服务热线:028-86922220
TOP