gpt4 book ai didi

android - 在android中检测Sdcard?

转载 作者:太空狗 更新时间:2023-10-29 15:56:17 25 4
gpt4 key购买 nike

如果使用内部存储器挂载,我正在使用以下代码访问 sdcard:

 if( android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
{
//File file = Environment.getExternalStorageDirectory();

videoPath=Environment.getExternalStorageDirectory()+"/cue_learn_data/video_files/"+VIDEO_FILENAME+".mp4";

}
else
{

videoPath="/cue_learn_data/video_files/"+VIDEO_FILENAME+".mp4";

}

但是当我使用第一个条件时找不到 vidoePath。有人可以帮忙吗?

最佳答案

尝试这样做:

String tmp = "/cue_learn_data/video_files/"+VIDEO_FILENAME+".mp4";
File myFile= new File(Environment.getExternalStorageDirectory(), tmp);

if(myFile.exists()){
//further processing as your file exists
}
else{
//seems like your file doesnt exist
}

关于android - 在android中检测Sdcard?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8906418/

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