RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
内存卡的数据保存与读取

,内存卡

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