harveyslash
harveyslash

Reputation: 6012

copying files from data/data/files/

I have a jpeg file created on this location /data/data/appname/files. I want it to be saved in the gallery of the user as a viewable picture. (internal memory preferred)

How do i go about it ?

(I am new at this , so please be elaborated)

Upvotes: 0

Views: 93

Answers (1)

kvh
kvh

Reputation: 2158

If this what you want?

1.decode bitmap from file

            Bitmap tempBitmap = BitmapFactory.decodeFile(fileName);

2.save image to gallery

     MediaStore.Images.Media.insertImage(getContentResolver(), yourBitmap, yourTitle , yourDescription);

And save image to internal memory:

String filePath = mContext.getCacheDir()+"YOUR_FILE_NAME";
File file = new File(filePath);
FileOutputStream os = null;
try {
     os = new FileOutputStream(file);
     if (null != os) {
     bmp.compress(Bitmap.CompressFormat.PNG, 100, os);
     os.flush();
     }
 } catch (Exception e) {
     e.printStackTrace();
   } 

Upvotes: 1

Related Questions