久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <legend id='A9qpi'><style id='A9qpi'><dir id='A9qpi'><q id='A9qpi'></q></dir></style></legend>
    1. <small id='A9qpi'></small><noframes id='A9qpi'>

    2. <tfoot id='A9qpi'></tfoot>
      <i id='A9qpi'><tr id='A9qpi'><dt id='A9qpi'><q id='A9qpi'><span id='A9qpi'><b id='A9qpi'><form id='A9qpi'><ins id='A9qpi'></ins><ul id='A9qpi'></ul><sub id='A9qpi'></sub></form><legend id='A9qpi'></legend><bdo id='A9qpi'><pre id='A9qpi'><center id='A9qpi'></center></pre></bdo></b><th id='A9qpi'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='A9qpi'><tfoot id='A9qpi'></tfoot><dl id='A9qpi'><fieldset id='A9qpi'></fieldset></dl></div>

          <bdo id='A9qpi'></bdo><ul id='A9qpi'></ul>

        數據目錄在Android中沒有讀/寫權限

        Data directory has no read/write permission in Android(數據目錄在Android中沒有讀/寫權限)

          1. <small id='52lTW'></small><noframes id='52lTW'>

            <legend id='52lTW'><style id='52lTW'><dir id='52lTW'><q id='52lTW'></q></dir></style></legend>
            • <bdo id='52lTW'></bdo><ul id='52lTW'></ul>
                  <tbody id='52lTW'></tbody>
                <tfoot id='52lTW'></tfoot>
                • <i id='52lTW'><tr id='52lTW'><dt id='52lTW'><q id='52lTW'><span id='52lTW'><b id='52lTW'><form id='52lTW'><ins id='52lTW'></ins><ul id='52lTW'></ul><sub id='52lTW'></sub></form><legend id='52lTW'></legend><bdo id='52lTW'><pre id='52lTW'><center id='52lTW'></center></pre></bdo></b><th id='52lTW'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='52lTW'><tfoot id='52lTW'></tfoot><dl id='52lTW'><fieldset id='52lTW'></fieldset></dl></div>
                  本文介紹了數據目錄在Android中沒有讀/寫權限的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我使用的是 Android 1.5 我的數據目錄沒有讀/寫權限

                  I m using Android 1.5 my data directory doesn't have the read/write permissions

                  System.out.println("DAta can write??--->"+Environment.getDataDirectory().canWrite());
                  System.out.println("DAta can read??--->"+Environment.getDataDirectory().canRead());
                  

                  所以請建議我如何為數據目錄提供權限.

                  So please suggest me how to provide permissions for the data directory.

                  我要做的是創建一個文件并在模擬器的數據存儲中添加一些內容,如下所示

                  What I'm trying to do is to create a file and add some content to it in the Data storage of the emulator like as below

                  private void writeToSDCard() {
                          try {
                  
                              File lroot = Environment.getDataDirectory();
                  
                              if (lroot.canWrite()){
                                  File lfile = new File(lroot, "samplefile.txt");
                                  FileWriter lfilewriter = new FileWriter(lfile);
                                  BufferedWriter lout = new BufferedWriter(lfilewriter);
                                  lout.write("XXXXXXXXXXXXXXXXXX");
                                  lout.close();
                              }
                          } catch (IOException e) {
                              Log.e(m_cTAG, "Could not write file " + e.getMessage());
                          }
                      }
                  

                  推薦答案

                  您不應該查看數據目錄.這是手機存儲中的系統目錄 - 通常是 /data - 您的應用程序永遠不會有寫入權限.

                  You shouldn't be looking at the Data Directory. This is a system directory in the phone's storage - usually /data - and your application will never have permission to write to it.

                  您的應用程序應該寫入文件的目錄由 返回Context.getFilesDir() 方法.它將類似于 /data/data/com.yourdomain.YourApp/files.

                  The directory your application should write files to is returned by the Context.getFilesDir() method. It will be something like /data/data/com.yourdomain.YourApp/files.

                  如果您想寫入手機存儲中的文件,請使用 Context.openFileOutput() 方法.

                  If you want to write to a file in the phone's storage use the Context.openFileOutput() method.

                  如果您想要 SDCard 的路徑,請使用 Environment.getExternalStorageDirectory() 方法.要寫入 SDCard,您需要通過將以下內容添加到您的 Manifest 來為您的應用程序授予適當的權限:

                  If you want the path to the SDCard then use Environment.getExternalStorageDirectory() method. To write to the SDCard you'll need to give your application the appropriate permissions by adding the following to your Manifest:

                  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
                  

                  如果您要寫入 SDCard,您還需要使用 getExternalStorageState() 方法檢查其狀態.

                  If you're going to write to the SDCard you'll also need to check its state with the getExternalStorageState() method.

                  如果您要存儲與應用程序相關的小文件,那么這些文件可以進入手機的存儲空間而不是 SD 卡,因此請使用 Context.openFileOutput()Context.openFileInput() 方法.

                  If you're storing small files to do with your application then these can go into the phone's storage and not the SD Card, so use the Context.openFileOutput() and Context.openFileInput() methods.

                  所以在您的代碼中考慮如下內容:

                  So in your code consider something like:

                  OutputStream os = openFileOutput("samplefile.txt", MODE_PRIVATE);
                  BufferedWriter lout = new BufferedWriter(new OutputStreamWriter(os));
                  

                  這篇關于數據目錄在Android中沒有讀/寫權限的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Get user#39;s current location using GPS(使用 GPS 獲取用戶的當前位置)
                  IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                  How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                  How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網絡提供商)
                  Get current location during app launch(在應用啟動期間獲取當前位置)
                  locationManager.getLastKnownLocation() return null(locationManager.getLastKnownLocation() 返回 null)

                  • <legend id='R5hWA'><style id='R5hWA'><dir id='R5hWA'><q id='R5hWA'></q></dir></style></legend>

                      <i id='R5hWA'><tr id='R5hWA'><dt id='R5hWA'><q id='R5hWA'><span id='R5hWA'><b id='R5hWA'><form id='R5hWA'><ins id='R5hWA'></ins><ul id='R5hWA'></ul><sub id='R5hWA'></sub></form><legend id='R5hWA'></legend><bdo id='R5hWA'><pre id='R5hWA'><center id='R5hWA'></center></pre></bdo></b><th id='R5hWA'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='R5hWA'><tfoot id='R5hWA'></tfoot><dl id='R5hWA'><fieldset id='R5hWA'></fieldset></dl></div>
                        <tfoot id='R5hWA'></tfoot>

                            <tbody id='R5hWA'></tbody>
                            <bdo id='R5hWA'></bdo><ul id='R5hWA'></ul>

                            <small id='R5hWA'></small><noframes id='R5hWA'>

                            主站蜘蛛池模板: 欧美天堂一区 | 四虎成人免费电影 | 国产成人精品久久二区二区91 | 一区二区三区中文 | 97精品久久 | 99精品在线免费观看 | 午夜寂寞福利视频 | 在线亚洲免费视频 | 亚洲精品国产综合区久久久久久久 | 人人人人爽 | 久久久精品 | 欧美一级欧美三级在线观看 | 大学生a级毛片免费视频 | 一区久久 | 在线视频一区二区 | 久久99视频| 麻豆久久精品 | 不卡视频在线 | 午夜91| 日本一区二区三区四区 | 日韩欧美网 | 国产在线中文字幕 | 日韩欧美一区二区三区免费看 | 欧美乱码精品一区二区三区 | 久久久久国产一区二区三区四区 | 日韩精品视频一区二区三区 | 中文字幕免费视频 | 国产欧美一区二区三区国产幕精品 | 二区中文 | 成年人在线观看 | 天天操操操操操 | 中文字幕亚洲一区二区va在线 | 久久精品一区二区三区四区 | 亚洲视频不卡 | 国产欧美日韩综合精品一区二区 | 欧美国产视频 | 玖玖综合在线 | 久久国产精品偷 | 亚洲色片网站 | 国产精品久久久久久 | 国产精品永久久久久 |