我正在尝试从"android.resource://" + getPackageName() + "/raw/video"
获取视频,并且它会完美地读取它。如何检查该文件是否存在或缺失?
答案 0 :(得分:1)
你可以这样检查。
int checkExistence = mContext.getResources().getIdentifier("FILENAME_WITHOUT_EXTENSION", "raw", mContext.getPackageName());
if ( checkExistence != 0 ) { // the resouce exists...
result = true;
}
else { // checkExistence == 0 // the resouce does NOT exist!!
result = false;
}