Note that there are some explanatory texts on larger screens.

plurals
  1. PONumbering of image saved from app resource to SD card
    primarykey
    data
    text
    <p>I have app consist of days listview each day has its specific images placed in an infinite gallery class , what im trying to do is:</p> <p><strong>saving images with sequential number from app drawable resource ( infinite gallery class) to sd card</strong>,</p> <p>im trying to get the sequential number of saved images as below :</p> <p>first image :Image-1.png .</p> <p>second image :Image-2.png .</p> <p>third image : Image-3.png , </p> <p>and so on for all dayes .</p> <p>with using :</p> <pre><code> Random generator = new Random(); </code></pre> <p><strong>This will lead to :</strong></p> <p><strong>first issue</strong> : saved images with random numbers .</p> <p><strong>second issue</strong> : its not saving all images was choose by user to save to sd card also it save some of image twice or three times .</p> <p><strong>This is the part of code which related to saving images :</strong></p> <pre><code> View vi=convertView; final ViewHolder holder; if(convertView==null){ vi = inflater.inflate(R.layout.gallery_items, null); holder=new ViewHolder(); holder.text=(TextView)vi.findViewById(R.id.textView1); holder.image=(ImageView)vi.findViewById(R.id.image); holder.button=(Button)vi.findViewById(R.id.button_save); bm = BitmapFactory.decodeResource( mContext.getResources(), images[itemPos]); holder.image.setImageBitmap(bm); holder.button.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { String root = Environment.getExternalStorageDirectory().toString(); File imagesFolder = new File(root + "/Days pictures"); imagesFolder.mkdirs(); Random generator = new Random(); int n = 1000; n = generator.nextInt(n); String fname = "Image-"+ n +".png"; File file = new File (imagesFolder, fname); if (file.exists ()) file.delete (); try { FileOutputStream out = new FileOutputStream(file); bm.compress(Bitmap.CompressFormat.PNG, 100, out); out.flush(); out.close(); Toast.makeText(mContext, "Saved", Toast.LENGTH_LONG).show();} catch (Exception e) { e.printStackTrace(); Toast.makeText(mContext, e.toString(), Toast.LENGTH_SHORT).show();}}}); vi.setTag(holder);} else holder=(ViewHolder)vi.getTag(); holder.text.setText(name[itemPos]); final int stub_id=images[itemPos]; holder.image.setImageResource(stub_id); return vi; } private ImageView getImageView() { ImageView i = new ImageView(mContext); return i; } } </code></pre> <p>thanks for your help .</p>
    singulars
    1. This table or related slice is empty.
    plurals
    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