gpt4 book ai didi

java - API 29 中的 AndroidStudio getExternalStoragePublicDirectory

转载 作者:行者123 更新时间:2023-11-30 04:57:57 24 4
gpt4 key购买 nike

在 API 29 中,getExternalStoragePublicDirectory 已被弃用,因此我必须找到将以下代码转换为 API 29 的方法

String pathSave = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
+ new StringBuilder("/GroupProjectRecord_")
.append(new SimpleDateFormat("dd-MM-yyyy-hh_mm_ss")
.format(new Date())).append(".3gp").toString();

感谢您的帮助!

最佳答案

如 android 文档中所述

Apps can continue to access content stored on shared/external storage by migrating to alternatives such as Context#getExternalFilesDir(String)

试试这个方法。

public void getFilePath(Context context){
String path = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)
+ new StringBuilder("/GroupProjectRecord_")
.append(new SimpleDateFormat("dd-MM-yyyy-hh_mm_ss")
.format(new Date())).append(".3gp").toString();

Log.d(TAG, "getFilePath: "+path);
}

关于java - API 29 中的 AndroidStudio getExternalStoragePublicDirectory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58794534/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com