Ali Hassan Ali Hassan - 1 year ago 70
Android Question

Android application file path

So I've built some code to download a file which works fine and I have set it to download into the applications directory which works. it's stored in the application folder /files/dltest

My issue is with checking programatically wether or not the file exists, I've tried methods one stackoverflow and for some reason I can only get my hard coded path to work.


Using built in methods to retrieve the path gives me the same path but with /data/data/com.... and this doesn't work

Answer Source
File mydir = context.getFilesDir();
File fileWithinMyDir = new File(mydir, "myfile/path/fileNmae");
    //not  exists


        //File mydir = this.getFilesDir();
        File mydir = this.getExternalFilesDir("/dltest/REQS.pdf");
        if (mydir.exists()) {
        } else {
            //not  exists