title: How to make picture with desired file name in Android?
body: <p>I have Android application which can take pictures and after the picture is taken it saves a filename into database. Later on when i transfer data from Android app to WebServer i would like that those filenames can be used for preview of those pictures in another application. So i have to worry that names in database and name of picture are consisted and that all pictures taken from my application are in some specific folder (for example "PictureFolder").
  So far i have 2 problems which i can't handle.</p>
  
  <p><strong>Problem 1</strong> </p>
  
  <p>I create desired name of picture like <code>picture_32016302_103500_bro_.jpg</code> and after in folder my Android app crates image in my specific folder but under name <code>picture_32016302_103500_bro_-67940687.jpg</code>. It's not this exact value every time, it's a random number for each picture. Why is this happening? Code is below</p>
  
  <pre><code>private static final int ActivityStartamera = 0;
  
  public void takePicture( View view)
  {
      Intent takePic= new Intent();
      takePic.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
      File photofile = null;
      try{
          photofile=createImageFile();
          takePic.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photofile));
          startActivityForResult(takePic, ActivityStartamera);
          Toast.makeText(this,Uri.fromFile(photofile).toString(), Toast.LENGTH_LONG).show();
      }
      catch (IOException e)
      {
          e.printStackTrace();
          Toast.makeText(this, "Error", Toast.LENGTH_LONG).show();
          imageFileName="";
      }
  }
  
  protected  void onActivityResult (int requestCode, int resultCode, Intent data)
  {
      if(requestCode == ActivityStartamera &amp;&amp; resultCode == RESULT_OK)
      {
          Toast.makeText(this, "Picture taken", Toast.LENGTH_LONG).show();
      }
      else{
          image.delete();
      }
  }
  
  File createImageFile () throws IOException{
      String timeStamp = new SimpleDateFormat("MyyyyMdd_HHmmss").format(new Date());
      imageFileName = "picture_"+timeStamp+"_bro_";
      storage = Environment.getExternalStoragePublicDirectory("PictureFolder");
      if (!storage.exists())
      {
          Toast.makeText(this, "Directory created", Toast.LENGTH_LONG).show();
          storage.mkdirs();
     }
      image = File.createTempFile(imageFileName, ".jpg", storage);
      return image;
  } 
  </code></pre>
  
  <p><strong>Problem 2</strong></p>
  
  <p>I want to transfer created pictures from app to PC with USB cable. When i connect my phone to PC, i go to folder "PictureFolder" and there i saw empty folder. After that i disconnect phone from PC, take a few photos with app, connect phone back to PC and the folder is still empty. If i restart phone then photos appear to folder. So i was skeptical and installed File explorer on phone and i saw that pictures taken from app appear on that folder, but only after restart they appear in PC file explorer. Is there any way to fix this? Or i will have to restart my phone before transfer of images? Does the folder content saves to some cache file or where is problem?</p>
  
  <p>I use HTC desire 610 and Caterpillar b15q and in both devices i have this problem so i think that it doesn't depends on which phone is the app installed.</p>