内存卡的数据保存与读取

,内存卡

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

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 外贸网站建设 成都网站设计 成都定制网站建设 成都网站建设 成都网站建设公司 成都企业网站制作 古蔺网站建设 营销型网站建设 网站建设费用 重庆网站设计 LED网站设计方案 盐亭网站设计 网站建设公司 成都模版网站建设 公司网站建设 上市集团网站建设 成都网站制作 成都网站设计 app网站建设 手机网站设计 教育网站设计方案 响应式网站设计方案