10-11-2012 01:46 AM
Hello everyone,
I have an app where I create an image file, upload it and then delete it. The first two work fine but when I try to delete the file, it shows an Exception that the File is currently in use. How can I delete this file. Can somebody help.
Thanks you.
10-11-2012 01:51 AM - edited 10-11-2012 01:52 AM
Here is my code:
try{
FileConnection f=null;
OutputStream out=null;
filename=getCurrDateTime();
f=(FileConnection) Connector.open("file:///store/home/user/_"+filenam e+".jpg",Connector.READ_WRITE);
f.create();
out=f.openOutputStream();
out.write(getBytes());
out.close();
StringBuffer connectionStr=new StringBuffer("http://www.myserver.com/bb/upload.php);
connectionStr.append(getString());
//upload image
sendImg(connectionStr.toString());
//delete file
f.delete();
f.close();
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println("====Exception: "+e.getMessage());
}
10-11-2012 03:26 AM
10-11-2012 07:26 AM
And how should I do that? When should I start deleting the file, till what time should I wait?
10-12-2012 01:28 AM
Now what I have done is, on the powerOff() event, I deleted the images I created. But I guess this is not an efficient method but it works. Can anybody suggest a better method?
10-12-2012 04:01 AM
10-16-2012 07:41 AM
Thanks for your reply, Simon. Yup I did it before. But I would like a method that could give me some sort of confirmation in this case.