如何在root / / samsung galaxy tab 10.1中创建文件夹?

时间:2013-11-21 05:01:48

标签: android makefile directory android-file

我想在我的三星galaxy tab10.1中创建像root / Myfolder一样的文件夹。我使用了Environment.getExternalStorageDirectory()但是它给了我mnt / sdcard而不是root /。任何人都知道如何获取我平板电脑根的路径?< / p>

 String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
 File folder = new File(extStorageDirectory+"/download/", "MyPdf"); 
// folder = new File("/root/download/", "MyPdf"); 
if(!folder.exists()) {
 folder.mkdir(); 
} 
File file = new File(folder, "Read.pdf"); 
try {
 file.createNewFile(); 
} catch (IOException e1) { 
   e1.printStackTrace(); 
} 

1 个答案:

答案 0 :(得分:0)

尝试一下

 File mydir = context.getDir("dir", Context.MODE_PRIVATE); 
    if(!mydir.exists)
    {
         mydir.mkdirs();
    }

Add permission in android manifest file 

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

或尝试

String path = Environment.getExternalStorageDirectory().getAbsolutePath()+"/MyPdf";
File dir = new File(path);
if (!dir.exists()){
    dir.mkdirs();
}