1

I get this error from Eclipse:

The constructor File(List<String>) is undefined

at this part of the code

 public void deleteFunction(int id){ 
         Toast.makeText(this, "Sters", Toast.LENGTH_SHORT).show();
        File file = new File(path); 
         boolean deleted = file.delete();
        }  
5
  • What is the path variable? Is it a List<String>? If so that's probably your problem. Commented Feb 5, 2013 at 19:47
  • @nick How can resolve that ? Commented Feb 5, 2013 at 19:47
  • There are a couple ways. If path is supposed to be a String then change its type to String. If it's supposed to be a List<String> then you would want something like File file = new File(path.get(0)); Commented Feb 5, 2013 at 19:49
  • @nick thank now it work but i give another error... The value of the local variable deleted is not used I'm n00b at java. Commented Feb 5, 2013 at 19:51
  • That means exactly what it's saying. That the variable deleted is never used. You need to either use the variable somehow (ie to do some kind of checking for successful deletion), or just eliminate the variable all together. It's been a while since I've used java but I think that's the right path. Commented Feb 5, 2013 at 19:54

2 Answers 2

1

because path is ArrayList and you will need to pass path of file from path ArrayList instead of whole ArrayList change your code as:

 public void deleteFunction(int id){ 
         //...
         if(id<path.size()){
          File file = new File(path.get(id)); 
          boolean deleted = file.delete();
         }
        }  
Sign up to request clarification or add additional context in comments.

7 Comments

the app dosen't crash but the file isn't deleted. In logcat i don't se any error.
Thak for help :) But you can help me with entire code ? I get this err <b>The value of the local variable deleted is not used</b>
@RaulPetrescu : i saw your previous code can u plz send me latest pastebin.com/YaQ35Lt8 class
I upload the source here. mega.co.nz/…
@RaulPetrescu : i mean post me link of latest class code then i will try to help u
|
1

It simply means there's no File constructor taking a list of strings.

1 Comment

can you help me to make File constructor ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.