简体   繁体   English

如何在 Android 10 的内部存储中创建我的自定义目录(文件夹)并存储我的数据?

[英]How do I make my custom directory(folder) in Android 10's Internal storage and store my data?

I am perfectly able to generate a PDF and store it in my custom made folder in Android SDK's version=<28 but as of Android 10我完全能够生成 PDF 并将其存储在我的自定义文件夹中 Android SDK 的版本 = <28 但截至 Android 10

 customFolder = new File(getExternalStorageDirectory() + File.separator + "TimingNotezz");
 customFolder.mkdirs();

customFolder.mkdirs() is false which means folder is not created, so customFolder.mkdirs()为 false 表示未创建文件夹,因此

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) 
{
    //I want to implement the code to create and store contents in a custom directory specifically for 
    // Android 10 here
} 

How can I do that?我怎样才能做到这一点? Thanks in advance.提前致谢。 I would love to have different suggestions.我很想有不同的建议。

You can use Intent.ACTION_OPEN_DOCUMENT_TREE to let the user choose a storage location.您可以使用 Intent.ACTION_OPEN_DOCUMENT_TREE 让用户选择存储位置。 Then after that create your "TimingNotezz" folder in it using storage access framework.然后使用存储访问框架在其中创建您的“TimingNotezz”文件夹。 Also your file you should create using saf.您还应该使用 saf 创建文件。

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

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