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.
Related
I am working on a chat application where I am sending/receiving Images/ Media. I am writing those files in a directory both sent and received.
Now the problem is if I send an image from gallery in chat I am copying it into Sdcardpath + AppName/Images/Sent/.
I this case the images in sent folder are duplicate.
And gallery app is Showing Sent folder with images. I need a way so that gallery cannot read the SentFolder. Below is my code for creating directory.
public static File getImageSentDirectory() {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
File dir = new File(Environment.getExternalStorageDirectory() + DOCUMENT_FILE_SENT_PATH);
if (!dir.exists())
dir.mkdirs();
return dir;
} else {
File dir = new File(getAppContext().getFilesDir() + DOCUMENT_FILE_SENT_PATH);
if (!dir.exists())
dir.mkdirs();
return dir;
}
}
I also tried .
dir.setWritable(true,true);
dir.setReadable(true,true);
But on restart device gallery app is showing the sent folder with images .
Add a .nomedia file in your "Sent" directory.
This will make the "Gallery" app skip your folder and thus it won't be listed.
The .nomedia file is like this inside WhatsApp media directory. It is a zero byte file.
I need a way so that galery can not read the SentFolder.
Do not put SentFolder on external storage. Put it on internal storage.
The .nomedia suggestion may help, but it is a convention, not a rule. Any app that has read access to external storage can get to any files you put on external storage. If you do not want that, do not put the files on external storage.
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 ?
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