listview.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { String item = (String) listview.getItemAtPosition(position); SharedPreferences Addresses = getSharedPreferences(FileListenerActivity.PREFS_NAME, 0); SharedPreferences.Editor editor = Addresses.edit(); editor.remove(item); editor.commit(); Toast.makeText(getBaseContext(), item + "被删除了", Toast.LENGTH_SHORT).show(); list.remove(item); adapter.notifyDataSetChanged(); return true; } });