title: how can i overwrite a file if it exists in directory
body: <p>i'm saving image in my directory with same name (for a purpose) but when file is already exists there it won't get overwritten , how do i know that ? because when i'm saving this file the already existing file is not changing but when i use a different name for my file it works. so what i want is to replace the existing file with a new one. so far this is what i'm trying :</p>
  
  <pre><code> content.setDrawingCacheEnabled(true);
                  Bitmap bitmap = content.getDrawingCache(); // an bitmap file for saving
  
  
                  File file = new File(context.getApplicationContext().getFilesDir() + "/img.jpg"); //here's the path where i'm saving my file
  
                  if (file.exists()){
  
                      file.delete(); // here i'm checking if file exists and if yes then i'm deleting it but its not working 
                  }
  
  
                  String path = file.getPath();
  
                  try {
                      file.createNewFile();
                      FileOutputStream ostream = new FileOutputStream(file);
                      bitmap.compress(Bitmap.CompressFormat.JPEG, 60, ostream);
  
  
                      savedFile = new File(path);
  
  
                      ostream.close();
                  }
                  catch (Exception e)
                  {
                      e.printStackTrace();
  
                  }
  </code></pre>
  
  <p>i'm doing another check right after deleting existing file :</p>
  
  <pre><code>                if (file.exists()){
  
                      Toast.makeText(context , "Still EXISTS",Toast.LENGTH_SHORT).show();
                  }
  </code></pre>
  
  <p>and this time file is not here cause the toast is not appearing.</p>