delete-file

Android, delete files in my data directory?

自作多情 提交于 2019-12-02 02:39:04
问题 My application stores some files that are required for it to run in the data directory of the app /data/data/com.example.myapp/files/filehere.file When my application is updated from the market, it is important that I clear the files in the data directory, and update them to the latest ones from the new package that has just been downloaded. My question is, how do I programatically delete the files in the directory in question? Alternatively, is there an alternative directory that I can store

Deleting file from sdcard in android

流过昼夜 提交于 2019-12-02 02:34:53
问题 I am making an app in which I have to delete the recently added mp3 file in sdcard. The format in which the song is saved is: Songhello_17_26.amr where 17_26 is the time when song was added. Can anyone help me how delete the recently added file in sdcard. I mean to say that I want to delete the time means the latest added file should get deleted. Any help will be appreciated. 回答1: As it states here, you cant do that directly, you first need to get list of files File.listFiles() , Comparator ,

Deleting file from sdcard in android

核能气质少年 提交于 2019-12-01 21:22:55
I am making an app in which I have to delete the recently added mp3 file in sdcard. The format in which the song is saved is: Songhello_17_26.amr where 17_26 is the time when song was added. Can anyone help me how delete the recently added file in sdcard. I mean to say that I want to delete the time means the latest added file should get deleted. Any help will be appreciated. Mohammed Azharuddin Shaikh As it states here , you cant do that directly, you first need to get list of files File.listFiles() , Comparator , File.lastModified() , Arrays.sort() and delete. Edited: File f = new File(path)

Java File.delete() does not delete all files

时光总嘲笑我的痴心妄想 提交于 2019-12-01 19:15:54
I have the following Java code which iterates through all the files in a directory and deletes them. for(File file : tmpDir.listFiles()) { file.delete(); } It does however not delete all files. Some, usually 20-30, out of a couple of thousand, are left behind when I do this. Is it possible to fix this, or have I stumbled upon some Java voodoo that is best left alone? It returns a boolean value, you should check that. From the JavaDoc : Returns: true if and only if the file or directory is successfully deleted; false otherwise You should check the value of the return and take action. If it

PHP recursive delete function

有些话、适合烂在心里 提交于 2019-12-01 18:03:35
I wrote recursive PHP function for folder deletion. I wonder, how do I modify this function to delete all files and folders in webhosting, excluding given array of files and folder names (for ex. cgi-bin, .htaccess)? BTW to use this function to totally remove a directory calling like this recursive_remove_directory('path/to/directory/to/delete'); to use this function to empty a directory calling like this: recursive_remove_directory('path/to/full_directory',TRUE); Now the function is function recursive_remove_directory($directory, $empty=FALSE) { // if the path has a slash at the end we remove

Close a file created with FileOutputStream, for a next delete

五迷三道 提交于 2019-12-01 17:24:20
I am currently facing some problem with a FileOutputStream in my Java code. Actually I am using a FileOutputStream for creating a file, but then once the file is created there is no way for deleting it. As far as I could understand, this may come from the fact that the FileOutputstream is not closed. On below my summarized code : outFile = new FileOutputStream(dir+"\\"+fileName); outFile.write("Test"); outFile.flush(); outFile.close(); outFile = null; System.gc(); Then there is no way to delete the file, even "by hand". When my program is launched, I can't delete it on windows by a simple del.

CURL command line tool - Delete File from FTP server

眉间皱痕 提交于 2019-12-01 16:38:23
I'm actually trying to use CURL to make some operations on a ftp server in C++ with Visual Studio. I've no trouble to do some uploads or downloads with commande line tools. But for deleting some file I have some errors. Here is the command I type: curl -v -u username:pwd ftp://host/FileTodelete.xml -Q '-DELE FileTodelete.xml' This is the answer: * Adding handle: conn: 0x1ca5260 * Adding handle: send: 0 * Adding handle: recv: 0 * Curl_addHandleToPipeline: length: 1 * - Conn 0 (0x1ca5260) send_pipe: 1, recv_pipe: 0 * About to connect() to host port 21 ( * Trying ...... * Connected to host (...)

Delete file after sharing via intent

妖精的绣舞 提交于 2019-12-01 15:43:29
问题 I'm trying to delete a temporary file after sharing it via android's Intent.ACTION_SEND feature. Right now I am starting the activity for a result and in OnActivityResult, I am deleting the file. Unfortunately this only works if I am debugging it with a breakpoint, but when I let it run freely and say, email the file, the email has no attachment. I think what is happening is my activity is deleting the file before it had been emailed. What I don't get is why, shouldn't onActivityResult only

CURL command line tool - Delete File from FTP server

放肆的年华 提交于 2019-12-01 15:20:46
问题 I'm actually trying to use CURL to make some operations on a ftp server in C++ with Visual Studio. I've no trouble to do some uploads or downloads with commande line tools. But for deleting some file I have some errors. Here is the command I type: curl -v -u username:pwd ftp://host/FileTodelete.xml -Q '-DELE FileTodelete.xml' This is the answer: * Adding handle: conn: 0x1ca5260 * Adding handle: send: 0 * Adding handle: recv: 0 * Curl_addHandleToPipeline: length: 1 * - Conn 0 (0x1ca5260) send

Delete Audio From Sdcard

拈花ヽ惹草 提交于 2019-12-01 11:51:56
I'm trying to delete an audio file in the SD-card but I'm not successful public boolean delete(String path) { return new File(path).delete(); } While going through posts I came across Storage Access Framework but unable to understand. Is it required for deleting files from SD-card? Moreover Can I only use Content Resolver to delete Files Like this? getContenResolver().delete(uri,null,null); Or is there any other method for deleting Audio? My app is well elevated with Write permission and Read permission and I am testing on Marshmallow 6.0 Please answer. Thanks in advance. You need to ensure