亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

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

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

數據的保存和讀取

發布時間:2020-07-14 13:58:41 來源:網絡 閱讀:566 作者:lang螞蟻 欄目:軟件技術

1數據的保存

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

                                        }else{

                                                   

                                                  String name="data.txt";

                                                  String content=user+"="+pwd;

                                                  try {

                                                   FileOutputStream fos=openFileOutput(name, MODE_PRIVATE);

                                                  

                                                   fos.write(content.getBytes());

                                                  

                                                   fos.close();

                                                             

                                                   Toast.makeText(getApplicationContext(), "保存成功", 200).show();

                                                   

                                                  } catch (Exception e) {

                                                            // TODO Auto-generated catch block

                                                            e.printStackTrace();

                                                  }

                                        }

                               

                              }

                    });

 

 

 

 

2,數據的讀取

 

 

btn_show.setOnClickListener(new OnClickListener() {

                               

                              @Override

                              public void onClick(View v) {

                                        String name="data.txt";

                                        try {

                                                  FileInputStream fis=openFileInput(name);

                                                  BufferedReader br=new BufferedReader(new InputStreamReader(fis));

                                                  //讀取文檔的數據

                                                  String content = br.readLine();

                                                  //拆分字符串

                                                  String[] strs = content.split("=");

                                                  //顯示的數據

                                                  if(!content.isEmpty()){

                                                            et_user.setText(strs[0]);

                                                            et_pwd.setText(strs[1]);

                                                  }

                                        } catch (Exception e) {

                                                  // TODO Auto-generated catch block

                                                  e.printStackTrace();

                                        }          

                              }

                    });

 

向AI問一下細節

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

AI

防城港市| 颍上县| 大洼县| 夏邑县| 武定县| 六安市| 时尚| 宿州市| 麻江县| 万宁市| 临夏县| 获嘉县| 吴旗县| 东宁县| 阳春市| 江口县| 肃宁县| 钟山县| 冕宁县| 甘德县| 噶尔县| 子长县| 清水县| 时尚| 九寨沟县| 遵义县| 泰州市| 东乡县| 涞水县| 祁阳县| 宜丰县| 屏南县| 温宿县| 台前县| 永清县| 锦屏县| 读书| 吉首市| 资讯| 楚雄市| 武乡县|