內(nèi)存卡的數(shù)據(jù)保存與讀取-創(chuàng)新互聯(lián)

,內(nèi)存卡

成都創(chuàng)新互聯(lián)公司網(wǎng)站建設(shè)公司,提供網(wǎng)站制作、成都做網(wǎng)站,網(wǎng)頁設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);可快速的進行網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,是專業(yè)的做網(wǎng)站團隊,希望更多企業(yè)前來合作!

   2.1數(shù)據(jù)保存

File file=newFile(Environment.getExternalStorageDirectory(), name);

                                                 try{

                                                           FileOutputStream   fos=newFileOutputStream(file);

                                                           fos.write(content.getBytes());

                                                           fos.close();

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

                                                 }  catch(Exception e) {

                                                              Toast.makeText(getApplicationContext(), "保存失敗", 200).show();

                                                           e.printStackTrace();

                                                 }

            

2.2數(shù)據(jù)讀取

File file=newFile(Environment.getExternalStorageDirectory(), name);

                                                 try{

                                                           FileOutputStream   fos=newFileOutputStream(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(newOnClickListener() {

                      

                             @Override

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

                                                                //保存數(shù)據(jù)

                                                    edit.putString("name", user);

                                                    edit.putString("pwd", pwd);

                                                    //提交保存

                                                    edit.commit();  

                                                 }                                

                             }

                   });

當前標題:內(nèi)存卡的數(shù)據(jù)保存與讀取-創(chuàng)新互聯(lián)
網(wǎng)頁URL:http://muchs.cn/article34/ioepe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設(shè)、建站公司、響應(yīng)式網(wǎng)站、手機網(wǎng)站建設(shè)靜態(tài)網(wǎng)站、營銷型網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管