This code attaches a specific picture in a folder :
File dir = Environment.getExternalStorageDirectory();
File file = new File(dir.getAbsolutePath()+ "/pictures/test.jpg");
m.addAttachment(file.toString());
m.send();
But i want my application attaches all photos are in a folder without specifying their name. Is it possible ?
Related
I have an android app where I am writing data (csv format) to the filesystem for export.
The app writes the file without any problem (I can see it in the file manager app). The issue is when I plug my device into my PC, the file doesn't show up?
I am writing to the downloads directory using this code to get the file path:
public File getDataStorageDir() {
// Get the directory for the user's public pictures directory.
File base = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
base = new File(base, "F3F");
base.mkdirs();
File file = new File(base.getAbsolutePath() + String.format("/%s.txt", mRace.name));
return file;
}
I can export the file to dropbox or email it, but I would also like to be able to plug in via usb and drag it off the filesystem. Could this be something to do with permissions?
Thanks
How to upload the entire folder of images (in the particular directory) onto Dropbox using Dropbox API?
In the sample code, it uploads the particular file which is of the same filename, however, I saved the image filenames according to the time at which it is taken and therefore, I was not able to upload any file saved.
I tried to use:
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
String imageFileName = "Pictures" + date.toString()+ ".jpg";
File file = new File(path+File.separator, imageFileName);
But no file was found when I tried uploading.
I'm trying to develop a simple android app. I want to know if an image exist in one of my apps' folder, but I don't know what's the root of my app. I tried...
File nomeFile = new File("res/drawable-hdpi/imagename.jpg")
File nomeFile = new File("myappanem/res/drawable-hdpi/imagename.jpg")
...but it doesn't work.
Try This :
File YourFile = new File(Environment.getExternalStorageDirectory(), "/Android/data/....yourfile.txt");
No you cant access drawable or manifest after packaging. because there will be no "drawable" folder or manifest file at all. All your drawables packed in APK file after installation. You cant reach them.
But you can access any folder of your phone in your app like that.
Firstly make directory.
File directory = new File(Environment.getExternalStorageDirectory()+File.separator
+"Your folder");
directory.mkdirs();
Access your folder like that.
String fileUrl = "/Your folder/a.png";
String file = android.os.Environment.getExternalStorageDirectory().getPath() +
fileUrl;
File f = new File(file);
whether your taking about internal memory of your application cache directory
//use this for internal memory
String path =Environment.getDataDirectory().getAbsolutePath();
File myImage=new File(path,"your file name.extension");
//use this for cache directory
String path=getApplicationContext().getDir("" , Context.MODE_PRIVATE);
File myImage=new File(path,"your file name.extension")
I need the route of a pdf file in my Android Project.
The file could be in raw or in assets folder.
I need to get the route because I must call using the File Class
Ex: File file = new File(path);
Thanks
Image:
http://img19.imageshack.us/img19/2303/capturaww.png
I am not quite sure what you mean, assuming you want to read to PDF file in your assets (res file) look here
Access PDF files from 'res/raw' or assets folder programmatically to parse with given methods
But if you want to get the file path of a folder, then look here
how to get file path from sd card in android
How to get the file path from URI?
Here is an example of how to get a file path (taken from the third link)
File myFile = new File(uri.toString());
myFile.getAbsolutePath()
I have successfully stored bitmap in sdcard/Pictures folder in android 2.X , using following code
File path = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
File file = new File(path, "pic"+index+".jpg");
now, i want to retrieve all the images stored in that folder with out specifying name of the file.
You can get a list of all the files in a directory with
http://developer.android.com/reference/java/io/File.html#listFiles()
You probably want to add a filefilter so that you only return jpg files you are interested in
File filters you can read about here
http://developer.android.com/reference/java/io/FilenameFilter.html