我可以从obb包中获取所有文件,但我无法检查包中是否存在特定文件。
在没有输入流或输入流的情况下,是否存在检查文件是否存在的简单方法。
public InputStream getInputStreamFromImage(Context mContext,String fileName)
{
String packageName = mContext.getPackageName();
File root = Environment.getExternalStorageDirectory();
File expPath = new File(root.toString() + "/Android/obb/"+ packageName);
try
{
if (expPath.exists()) {
String strMainPath = expPath
+ File.separator
+ "main."
+ mContext.getPackageManager().getPackageInfo(
mContext.getPackageName(), 0).versionCode + "."
+ packageName + ".obb";
File f=new File(strMainPath);
if(f.exists()){
Log.e("Path ", "=====>Exists");
}
else{
Log.e("Path ", "=====> Not Exists");
}
ZipResourceFile zip = new ZipResourceFile(strMainPath);
**// here i want to check a file exist with name or not**
InputStream iStream = zip.getInputStream(fileName+".jpg");
Log.e("URI ","=======>"+iStream.toString());
return iStream;
}
}
catch(Exception e)
{
}
return null;
}