Note that there are some explanatory texts on larger screens.

plurals
  1. PODelete function not working
    primarykey
    data
    text
    <p>I am developing an app which has a splash screen that downloads a couple of files, before the files start to download I want to check whether the files already exist or not, and if they exist I want to delete them. The code shown below contains the right file paths and the function to check if the file exists seems to work as the read out in Logcat states "file deleted". </p> <p>However when I check on the phone itself I see that whenever I launch the app 2 more files are added to the folder with the same file name but with increasing numbers </p> <p>e.g. Launch 1... I get </p> <pre><code>clientraw.txt clientrawextra.txt </code></pre> <p>Launch 2... I get </p> <pre><code>clientraw.txt clientrawextra.txt clientraw-1.txt clientrawextra-1.txt </code></pre> <p>and so on.....</p> <p>Therefore it would seem the delete function isn't working, any help would be appreciated!</p> <pre><code>//Code that checks if the clientraw.txt file already exists, if so the file is deleted File sdCard = Environment.getExternalStorageDirectory(); File file = new File(sdCard.getAbsolutePath() + "/Download", client); Log.d("file path", String.valueOf(file)); if (file.exists()) { file.delete(); Log.d("file", "file deleted"); } File sdCardextra = Environment.getExternalStorageDirectory(); File fileextra = new File(sdCardextra.getAbsolutePath() + "/Download", clientextra); if (fileextra.exists()) { fileextra.delete(); Log.d("file", "file deleted"); } ready(); </code></pre> <p>It seems that it doesn't delete the file fast enough? When I get rid of the <code>ready();</code> method (The method that downloads the files) it does delete the files fine, so I'm thinking that the files start downloading before the previous files are deleted really stuck on this one?!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload