简体   繁体   English

如何在android中访问特定的内部存储目录?

[英]How to access a particular internal storage directory in android?

I am trying to learn android programming. 我正在尝试学习android编程。 As a beginning, I am trying to understand the internal file system & accessing them. 首先,我试图了解内部文件系统并对其进行访问。 Any help is highly appreciated. 非常感谢您的帮助。 Following are my challenges: 以下是我的挑战:

  1. How to create a 'TEST' folder through the android emulator/Android device monitor? 如何通过Android模拟器/ Android设备监视器创建“测试”文件夹? I need to create the folder where the alarms, download, DCIM folder are present. 我需要创建存在警报,下载,DCIM文件夹的文件夹。
  2. What is the absolute directory path to the 'TEST' folder created? 创建的“ TEST”文件夹的绝对目录路径是什么? Is it possible to access the TEST folder using the code below: 是否可以使用以下代码访问TEST文件夹:

     List<File> list = Environment.getDataDirectory()+"/TEST".listFiles(); 
  3. Does any permission to be mentioned in the manifest for read/write to internal storage? 在清单中提及对内部存储进行读写的权限吗?

PS: I use Android Studio. PS:我使用Android Studio。

You would want something along the lines of 您会想要一些类似的东西

File TEST = new File(Environment.getExternalStorageDirectory(), "TEST");
TEST.mkdir(); // make directory may want to check return value
String path = TEST.getAbsolutePath(); // get absolute path

and permissions 和权限

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

Further reference 进一步参考

File file = new File("storage/emulated/0","yourfoldername/");

如果这没有帮助,则对我有用,然后在使用

File(Environment.getobbdir(),"yourfoldername");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM