我有这段代码可以删除我之前创建的文件夹下的特定文件“pass”,我想要的是删除用户单击的任何文件,而不是这个特定文件“myfile”
public void function1(int id){
Toast.makeText(this, "function 1 called", Toast.LENGTH_SHORT).show();
String fileName = Environment.getExternalStorageDirectory() +"/pass/myfile.pdf";
File myFile = new File(fileName);
if(myFile.exists())
myFile.delete();
我一直在尝试将参数从另一个类传递给这个类,但它不起作用
file_name = getIntent().getStringExtra("fileName");
String fileName = Environment.getExternalStorageDirectory() +"/pass/"+file_name;
File myFile = new File(fileName);
if(myFile.exists())
myFile.delete();
此类传递文件名
if (position == 0) {
// pass parameters file name & file url
Intent s = new Intent(getApplicationContext(),PDFListActivity.class);
s.putExtra("fileName","myfile.pdf");
startActivity(s);