-1

Is it possible to create a new folder for images (to be taken through my app) to be stored in, on the android phone? (Or SD Card as far as I'm concerned). I could name it what I like [Maybe the name of my app so the files are easily found] and then the images taken by launching the camera through my app will be stored there. I'm thinking it might have something to do with Uri's. (Just a guess.)

Cole
  • 2,805
  • 9
  • 44
  • 61
  • yes u can do it. you should start with how to create a directory in sdcard first, and then how to write images to it. simple. – Andro Selva Jun 16 '12 at 05:44

3 Answers3

4

use this code

String root = Environment.getExternalStorageDirectory().toString();
File myDir = new File(root + "/saved_images");   
myDir.mkdirs();
Random generator = new Random();
int n = 10000;
n = generator.nextInt(n);
String fname = "Image-"+ n +".jpg";
File file = new File (myDir, fname);
if (file.exists ()) file.delete (); 
try {
       FileOutputStream out = new FileOutputStream(file);
       finalBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
       out.flush();
       out.close();

} catch (Exception e) {
       e.printStackTrace();
}

and add this in manifest

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 

check this link Android saving file to external storage

Community
  • 1
  • 1
RajaReddy PolamReddy
  • 22,428
  • 19
  • 115
  • 166
1

Just use File operation for that..

File imageDirectory = new File("/sdcard/Images/"); // Path for location where you want to make directory, Internal or External storage
// have the object build the directory structure, if needed.
imageDirectory.mkdirs();

And in Application's manifest file put permission..

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
user370305
  • 108,599
  • 23
  • 164
  • 151
1

Why not?

String path = Environment.getExternalStorageDirectory().getAbsoluteFile() + "/YourAppRootDir"; 
File dir = new File(path);
dir.mkdirs();
neevek
  • 11,760
  • 8
  • 55
  • 73