lv.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { HashMap map = (HashMap) music_name.get(position); final String abc = (String) map.get("data"); String na = (String) map.get("name"); final AlertDialog.Builder ab = new AlertDialog.Builder(BofangActivity.this); ab.setTitle("是否删除该歌曲 ==>"+na); ab.setMessage("删除该歌曲,"); ab.setPositiveButton("删除", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { File mf = new File(abc); if(mf.exists()){ mf.delete(); Toast.makeText(BofangActivity.this, "OK成功删除", Toast.LENGTH_LONG).show(); }else { Toast.makeText(BofangActivity.this, "该文件不存在", Toast.LENGTH_LONG).show(); } } }).setNegativeButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); ab.create(); ab.show(); return false; } });
思路是百度上看到的
File file = new File("sd/file1.txt");
if(file.exists())
file.delete();
下面的连接是 雨松的
Android软件开发之数据的新建 储存 读取 删除
----- 还没看,有时间得看看。
http://blog.csdn.net/xys289187120/article/details/6645629
`