Reputation: 1
I just started developing an android app so I need your help guys.
Here's my code.
private File createImageFile() throws IOException{
File image = null;
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); //Get Date
String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES); //Get the directory of pictures
if (isExertnalStorageWritable()){
if(isExternalStorageReadable()) {
image = File.createTempFile(imageFileName, ".jpg", storageDir); //Create the temp file
mCurrentPhotoPath = image.getAbsolutePath();
}
}
return image;
}
but my temp file is always being created in the internal storage, not in the External storage.
Upvotes: 0
Views: 4984
Reputation: 2710
// Use this code changes to make your data to be stored in your external storage
File storageDir = getExternalFilesDir("Pictures");
Upvotes: 1
Reputation: 1
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
I believe in this line you are asking for the directory of pictures that are listed for the user. Try pasing null instead like this:
File storageDir = getExternalFilesDir(null);
Let me know if that worked for you! Good luck!
Upvotes: 0