문제

I want to search a file in mobile which may present in SDcard or else where.After finding the file i should delete the file.Both process like searching and deletion should be done in back ground without knowing the user .How to implement this can any one help me..

도움이 되었습니까?

해결책 2

Fist you have to find the file. Start in root directory, list all entries and compare them with your pattern. If not found, go into each of the listed directories and repeat the process. Keywords: depth first search, recurrency.

You can delete the file using File.delete method. As simple as that. Also, you will need WRITE_EXTERNAL_STORAGE permission.

See: http://developer.android.com/reference/java/io/File.html

다른 팁

for searching the file named "b.html" in folder named "a"...

File extStore = Environment.getExternalStorageDirectory();
File myFile = new File(extStore.getAbsolutePath() + "/a/b.html");

if(myFile.exists()){
    ...
}

and for deleting the file, see this...

How to delete a file from SD card?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top