Solution to getSelectionRowID() Android method error

I've tried to use the followign file browser function -> http://www.anddev.org/building_an_android_filebrowser_list-based_-t67.html within my Android Applicaiton and while running through Eclipse’s debug mode I was able to pin point the issue to the following snippet of code [int selectionRowID = (int) this.getSelectionRowID();]. The specific error shown by the compiler stated that method getSelectionRowID is of an unidentified type.

After extensive search on Google and other online resources I have returned back to the original application’s forum and in one thread (http://www.anddev.org/building_an_android_filebrowser_list-based_-t67-s15.html) discovered that ListActivity.getSelectionRowId() was removed from API by Android development team and that it was recommended to use ListActivity.getSelectedItemPosition() or getSelectedItemID() instead.  However, the new function may often return no selection (-1 or 0) more when the emulator or device is in touch mode.

While trying out new approach I’ve experienced a null pointer (both -1 and 0 for each of the suggested methods) error and found a lot of useful material online advising on how to resolve this issue. None of the methods however have really worked for me.

Instead, I've desided to use getItemAtPosition(position) method which identified a file name selected without ever determining its ID. I was therefore forced to recode the rest of the method due to the fact that it relied on the item ID which I was never able to indentify.

Please see my code snippet below ( I am recoding the onListItemClick within AndroidFileBrowser.js)

@Override
        protected void onListItemClick(ListView l, View v, int position, long id) {

            String position2 = (String) l.getItemAtPosition(position);

        String selectedFileString = position2;
       
                if (selectedFileString.equals(".")) {
                        // Refresh
                        this.browseTo(this.currentDirectory);
                } else if(selectedFileString.equals("..")){
                        this.upOneLevel();
                } else {
                        File clickedFile = null;
                        switch(this.displayMode){
                                case RELATIVE:
                                     
                                    clickedFile = new File(position2);
                                        break;
                                case ABSOLUTE:
                                        
                                    clickedFile = new File(position2);    
                                    break;
                        }
                        if(clickedFile != null)
                           
                                this.browseTo(clickedFile);
                }
        }

 

Please let me know if anyone has any comments or questions.