Android Listview Replacing Strings
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/14018950/android-replace-strings">Android Replace Strings</a>  </p>
</blockquote>



<p>Below is my listview. The data are gathered from the sdcard and listed out on a listview. But the filenames retrieved from the sdcard ends with ".txt" How do I remove the ".txt" from my listed filenames?   </p>

<pre><code>mainListView = (ListView) getActivity().findViewById( R.id.mainListView );

            myList = new ArrayList&lt;String&gt;();



                File sdCard = Environment.getExternalStorageDirectory();
                file = new File(sdCard.getAbsolutePath() + "/St/") ;       
                File list[] = file.listFiles();

                for( int i=0; i&lt; list.length; i++)
                {
                        myList.add( list[i].getName() );
                }



                listAdapter = new ArrayAdapter&lt;String&gt;(getActivity(),R.layout.simplerow, myList);

                mainListView.setAdapter( listAdapter );  

                mainListView.setOnItemClickListener(new OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                            int position, long id) {
                        // TODO Auto-generated method stub
                        String textToPass = myList.get(position);
                                Intent i = new Intent(getActivity(), ViewActivity.class);                      
                                i.putExtra("textToPass", textToPass);
                                startActivity(i);
                    }
                });
</code></pre>
