重庆分公司,新征程启航

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

内存卡的数据保存与读取

,内存卡

成都网站建设、成都网站制作中从网站色彩、结构布局、栏目设置、关键词群组等细微处着手,突出企业的产品/服务/品牌,帮助企业锁定精准用户,提高在线咨询和转化,使成都网站营销成为有效果、有回报的无锡营销推广。创新互联建站专业成都网站建设十年了,客户满意度97.8%,欢迎成都创新互联客户联系。

     2.1数据保存

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

                                                  try {

                                                            FileOutputStream   fos=new FileOutputStream(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=new File(Environment.getExternalStorageDirectory(), name);

                                                  try {

                                                            FileOutputStream   fos=new FileOutputStream(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(new OnClickListener() {

                               

                              @Override

                              publicvoid onClick(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://cqcxhl.com/article/giicih.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP