0

I am developing an Android app for API 2.3 and above. I am using the Android camera to take a picture and place the image in a specified file. This works, and once returned I use the file.exists command to check it does and then display it in an image view.

I later pass the image path into an object that gets stored on a DB. I later recall this object, get the path as a string, make a file object and pass it this string. After doing so I call file.exits() which returns true.

However, later on another thread (actually an intent service) I attempt to upload the picture fo a server using the org.apache.http.MultipartEntity and related libraries based approach.

Before I pass the file containing the image path to the multipartEntity I check the file exists. However this time it returns false.

Why would it do this? Why is there an inconsistency. Is there some security permission/feature I am overlooking?

Andrew S
  • 2,847
  • 3
  • 33
  • 50
  • "Why would it do this?" -- because the file doesn't exist. Perhaps the `File` object is malformed. Or perhaps the file was deleted. – CommonsWare Jun 13 '13 at 19:21
  • Unless the framework decided to remove it, highly unlikely. I make no calls to delete files until it has been flagged the image has uploaded successfully. I'll check my program closely though, by adding exists checks in several places to see when it goes.. – Andrew S Jun 13 '13 at 19:24
  • 1
    Log all uses of your `File` objects to see if the last one is malformed. – CommonsWare Jun 13 '13 at 19:26
  • yep that's it, found the problem. Turns out the code used to empty clear the input fields, and temorary image files when the user presses cancel, was also firing when the screeen closed. Thanks for your advice. – Andrew S Jun 13 '13 at 20:37

0 Answers0