How to check a file exist in obb package or not?

702 Views Asked by At

I am enable to get all the files from obb package but i am not able to check that a particular file exist in the package or not.

Is there any easy way to check a file exist or not without inputstream or with input stream.

 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;
    } 
0

There are 0 best solutions below