title: How to Generate Random names for Images while storing in Internal Memory?
body: <p>The Android Application which I am developing is basically a shopping application, which has a Cart option, where user can add items. </p>
  
  <p>The Items has Image, Name, Price etc..</p>
  
  <p>I get all these data from server.</p>
  
  <p>When user click "Add to Cart " option then a sqlite database is created  where I store the name, price and image path.</p>
  
  <p>Basically Imgaes are stored in the internal memory when add to cart is clicked and only image path is stored in the database.</p>
  
  <p><strong>Problem:</strong></p>
  
  <p>To store images in the internal memory I use the below code where I will give the file name myself (In this case I give file name as <strong>profile.jpg</strong>).</p>
  
  <p>SaveToMemory:</p>
  
  <pre><code> private String saveToInternalSorage(Bitmap bitmapImage){
      ContextWrapper cw = new ContextWrapper(getApplicationContext());
      // path to /data/data/yourapp/app_data/imageDir
       directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
      // Create imageDir
      mypath=new File(directory,"profile.jpg");
      FileOutputStream fos = null;
      try {
          fos = new FileOutputStream(mypath);
          // Use the compress method on the BitMap object to write image to the OutputStream
          bitmapImage.compress(Bitmap.CompressFormat.PNG, 100, fos);
      } catch (Exception e) {
          e.printStackTrace();
      } finally {
          try {
              fos.close();
  
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
      return directory.getAbsolutePath();
  
  }
  </code></pre>
  
  <p>LoadFromMemory:</p>
  
  <pre><code>private Bitmap loadImageFromStorage(String path)
  {
  
      try {
          File f=new File(path, "");
          f.canRead();
          b = BitmapFactory.decodeStream(new FileInputStream(f));
          return b;
  
  
      }
  </code></pre>
  
  <p>If I do so, latest image is overridden by the previous image. Iam not able to store multiple images in the internal memory.</p>
  
  <p>For Example If I add two items inside the cart I dont know how to store those two images and get it.</p>
  
  <p><strong>Aim</strong></p>
  
  <p>Need to store any number of images with random file name in the internal memory</p>
  
  <p>Store the file name in sqlite database.</p>
  
  <p>Retrieve it back to display in Imageview.</p>
  
  <p>Any help would be greatly thankfull.</p>