成都创新互联网站制作重庆分公司

内存卡的数据保存与读取

,内存卡

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

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部