内存卡的数据保存与读取-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

内存卡的数据保存与读取

,内存卡

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

其他资讯