Java项目错误

时间:2013-02-05 19:45:43

标签: java android

我从Eclipse中收到此错误:

The constructor File(List<String>) is undefined

代码的这一部分

 public void deleteFunction(int id){ 
         Toast.makeText(this, "Sters", Toast.LENGTH_SHORT).show();
        File file = new File(path); 
         boolean deleted = file.delete();
        }  

2 个答案:

答案 0 :(得分:1)

它只是意味着没有File构造函数获取字符串列表。

答案 1 :(得分:1)

因为路径是ArrayList而你需要从路径ArrayList而不是整个ArrayList传递文件路径,所以将代码更改为:

 public void deleteFunction(int id){ 
         //...
         if(id<path.size()){
          File file = new File(path.get(id)); 
          boolean deleted = file.delete();
         }
        }