中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

內存卡的數據保存與讀取

發布時間:2020-07-17 00:37:52 來源:網絡 閱讀:362 作者:lang螞蟻 欄目:軟件技術

,內存卡

     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

                              public void 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();          

                                                  }                                        

                              }

                    });


 


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

辽阳县| 田阳县| 唐河县| 临高县| 江门市| 南安市| 马关县| 锡林浩特市| 巢湖市| 梧州市| 宁河县| 新建县| 电白县| 大姚县| 呈贡县| 北票市| 临江市| 鞍山市| 通化市| 富川| 饶阳县| 霞浦县| 吉林市| 桐城市| 肇东市| 漠河县| 阜新市| 墨玉县| 建始县| 呼和浩特市| 乐平市| 唐山市| 甘谷县| 修水县| 满洲里市| 甘德县| 青阳县| 漾濞| 集安市| 文昌市| 马关县|