Q:

How to filter songs in listView

I have a listView filled up with all songs on sdcard, can i filter them by name using an ediText or something else (like a SearchBar) and update the listview?Thanks, this is how I fill up the listview:
@SuppressWarnings("deprecation")
    private void init_phone_music_grid() {
            System.gc();
            String[] proj = { MediaStore.Audio.Media._ID,
    MediaStore.Audio.Media.DATA,
    MediaStore.Audio.Media.DISPLAY_NAME,
    MediaStore.Video.Media.SIZE };
            musiccursor = managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
    proj, MediaStore.Audio.Media.DURATION + ">= 120000", null, null);
            count = musiccursor.getCount();
            musiclist = (ListView) findViewById(R.id.listView1);
            musiclist.setAdapter(new MusicAdapter(getApplicationContext()));

            musiclist.setOnItemClickListener(musicgridlistener);

            mMediaPlayer = new MediaPlayer();

      }

  private OnItemClickListener musicgridlistener = new OnItemClickListener() {
            public void onItemClick(AdapterView parent, View v, int position,
    long id) {

                System.gc();
                  music_column_index = musiccursor
    .getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
                  musiccursor.moveToPosition(position);

                  String filename = musiccursor.getString(music_column_index);
                  String canzone=filename.replace("/storage/sdcard0/", "");
                  canzone=canzone.replace("Music/", "");
                  canzone=canzone.replace("media/", "");
                  canzone=canzone.replace("Ringtones/", "");
                  t=(TextView) findViewById(R.id.textView2);
                  t.setWidth(130);
                  t.setSingleLine(true);
                  t.setText(canzone);

                  try {
                        if (mMediaPlayer.isPlaying()) {
                              mMediaPlayer.reset();
                        }
                        mMediaPlayer.setDataSource(filename);
                        mMediaPlayer.prepare();
                        mMediaPlayer.start();
                  } catch (Exception e) {

                  }
            }
      };         
      public class MusicAdapter extends BaseAdapter {
            private Context mContext;

            public MusicAdapter(Context c) {
                  mContext = c;
            }

            public int getCount() {
                  return count;
            }

            public Object getItem(int position) {
                  return position;
            }

            public long getItemId(int position) {
                  return position;
            }

            public View getView(int position, View convertView, ViewGroup parent) {
                System.gc();
                String id = null;
                TextView tv;
                if (convertView == null) {
                tv = new TextView(mContext.getApplicationContext());
                } else{
                tv = (TextView) convertView;
                }
                musiccursor.moveToPosition(position);
                music_column_index = musiccursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DISPLAY_NAME);
                id = musiccursor.getString(music_column_index);
                tv.setText(id);
                return tv;
                }
      }

This is the updated code:
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_player);
    progressBar = (ProgressBar) findViewById(R.id.progressBar1);
    init_phone_music_grid(null);
    //Controllo();
    edittext=(EditText) findViewById(R.id.editText1);
    edittext.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {

            }
            @Override
            public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
                    int arg3) { }

            @Override
            public void afterTextChanged(Editable arg0) {
                init_phone_music_grid(edittext.getText().toString());

            }
        });
}

@SuppressWarnings("deprecation")
    private void init_phone_music_grid(String a) {
            System.gc();
            String sortOrder=null;
            if(a!=null){
                sortOrder=MediaStore.Audio.Media.TITLE +a;
            }

            String[] proj = { MediaStore.Audio.Media._ID,MediaStore.Audio.Media.DATA,MediaStore.Audio.Media.DISPLAY_NAME,
    MediaStore.Video.Media.SIZE };
    musiccursor = managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
    proj, MediaStore.Audio.Media.DURATION + ">= 120000", null, sortOrder);
            count = musiccursor.getCount();
            musiclist = (ListView) findViewById(R.id.listView1);
            musiclist.setAdapter(new MusicAdapter(getApplicationContext()));

            musiclist.setOnItemClickListener(musicgridlistener);

            mMediaPlayer = new MediaPlayer();

      }

      private OnItemClickListener musicgridlistener = new OnItemClickListener() {
            public void onItemClick(AdapterView parent, View v, int position,
    long id) {

                System.gc();
                  music_column_index = musiccursor
    .getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
                  musiccursor.moveToPosition(position);

                  String filename = musiccursor.getString(music_column_index);
                  String canzone=filename.replace("/storage/sdcard0/", "");
                  canzone=canzone.replace("Music/", "");
                  canzone=canzone.replace("media/", "");
                  canzone=canzone.replace("Ringtones/", "");
                  t=(TextView) findViewById(R.id.textView2);
                  t.setWidth(130);
                  t.setSingleLine(true);
                  t.setText(canzone);

                  try {
                        if (mMediaPlayer.isPlaying()) {
                              mMediaPlayer.reset();
                        }
                        mMediaPlayer.setDataSource(filename);
                        mMediaPlayer.prepare();
                        mMediaPlayer.start();
                  } catch (Exception e) {

                  }

            }

      };

A:

this is how you sort stuffs from mediastore
String sortOrder = MediaStore.Audio.Media.TITLE + " ASC";

if you want to sort it by artists or something else..just replace the "TITLE"part with whatever you dersire..
If you find my answer useful,accept it 
Edit:Sorry i forgot where you will put this sort order thing
musiccursor = managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
    proj, MediaStore.Audio.Media.DURATION + ">= 120000", null, null);

in this line of node..replace the last "null" with sortorder,and you will get sorted list...

