Hey guys, below is my code for my program, it gives me a list of 
directories and it allows me to click through one directory, however if I 
try to click through to 2 folders deep it wont let me because of 
"if(K.getAbsoluteFile().isDirectory()==true)", and removing this gives me a 
crash.  Can anyone tell me why it wouldn't recognize "File K" as a 
directory the second click through in my browse class?  

 

> package book.BouncySquare;
>
>
>> import java.io.File;
>
> import java.util.ArrayList;
>
> import java.util.List;
>
> import android.app.ListActivity;
>
> import android.os.Bundle;
>
> import android.util.Log;
>
> import android.view.View;
>
> import android.widget.ArrayAdapter;
>
> import android.widget.ListView;
>
>
>> public class FileManager extends ListActivity {
>
> public File clickedFile = null;
>
> private List<String> directoryEntries = new ArrayList<String>();
>
>  //private List<String> directoryEntries = new ArrayList<String>();
>
> private File currentDirectory = new File("/");
>
>
>> @Override
>
> public void onCreate(Bundle icicle) {
>
> Log.d("startx", "start");
>
> super.onCreate(icicle);
>
> browseToRoot();
>
> }
>
>  
>> public void browseToRoot() {
>
> Log.d("Browse", "browse"+currentDirectory.getAbsoluteFile());
>
> browseTo(new File("/"));
>
> }
>
>
>>
>>
>> private void browseTo(File file) {
>
> Log.d("mew", "too");
>
> if(file.isDirectory()){
>
> Log.d("check", "it");
>
> fill(file); }
>
> }
>
>  private void browse(String x) {
>
> Log.d("created", "newfile");
>
> final File K=new File(x); 
>
> Log.d("broke", "ass");
>
> if(K.getAbsoluteFile().isDirectory()==true){
>
> Log.d("Z"+K.getAbsoluteFile(), "directory");
>
> fill(K.getAbsoluteFile());}
>
> else{
>
> Log.d("X"+K.getName(), "NotADirectoryOrHidden");
>
> Log.d("A"+K.getAbsoluteFile(), "directory");
>
> }
>
>  }
>
>
>>
>>
>> private void fill(File files) {
>
> File[] meow=null;
>
> this.directoryEntries.clear();
>
> meow= files.listFiles();
>
> Log.d("sss", "sss");
>
> this.directoryEntries.add(getString(R.string.current_dir));// 
>> directoryentries is an arraylist that holds our Directories names
>
> this.directoryEntries.add(getString(R.string.up_one_level));
>
> for (File file : meow) {
>
> this.directoryEntries.add(file.getName()); //fill our string array 
>> directoryentries with each files getName, then we pass it to arrayAdapter 
>> to populate
>
> }
>
> ArrayAdapter<String> directoryList = new 
>> ArrayAdapter<String>(this,R.layout.file_row, this.directoryEntries); //our 
>> context,layout, and array of directories is created
>
> this.setListAdapter(directoryList);
>
> }
>
>  @Override
>
> protected void onListItemClick(ListView l, View v, int position, long id) {
>
> String clickedEntry =this.directoryEntries.get((int) id);
>
> Log.d("clickedID="+id, "clickedPosition="+clickedEntry); 
>
> browse(clickedEntry);
>
> }
>
> }
>
>


 

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to