0
/android中的數據目錄爲空。我已經安裝了幾個應用程序,並且我還寫了代碼在/ data/Myapp目錄中創建一個文件,無法找到我在Android平板電腦上創建的文件
我在OnCreate方法中有這些行,但運行該程序後沒有在/ data目錄中看到任何文件。
File fileDir = getFilesDir();
String filedir=fileDir.toString();
Log.v("TEST","FILEDIR--->"+filedir);
//output i got is FILEDIR--->/data/data/com.android.Test/files
String strNewFileName = "test1.txt";
String strFileContents = " MY FIRST FILE CREATION PRGM";
File newFile = new File(fileDir, strNewFileName);
try{
boolean filestat = newFile.createNewFile();
Log.v("TEST"," CREATE FILE =>"+ filestat);
//output is CREATE FILE =>true indicating success
FileOutputStream fo =
new FileOutputStream(newFile.getAbsolutePath());
fo.write(strFileContents.getBytes());
fo.close();
}
catch(IOException e)
{Log.v("TEST","Exception on create ");}
我的應用程序如何獲得root訪問權限?我嘗試通過「andexplorer」查看,但顯示爲空。 http://www.lysesoft.com/products/andexplorer/ – m4n07 2011-03-28 11:38:14
應用程序無法正常訪問root權限。看到更新的答案。 – MByD 2011-03-28 11:40:30
createNewFile()函數返回true,這意味着該文件在創建時沒有任何問題。但生根適用於平板電腦?假設我正在開發獲取輸入的應用程序,並將處理後的輸入存儲在「/data/com.android.mypackage/files」中。假設用戶有興趣查看我創建的文件,那麼用戶無法使用我的應用程序而不生根? – m4n07 2011-03-28 12:00:00