如何在android**中打开"**sdcard文件",如果我点击它必须在模拟器中打开文件?

0 pdf android

如何在android中打开" sdcard文件 ",如果我点击它必须在模拟器中打开文件?

Bob*_*oid 5

public class Testopen extends Activity {
    private List<String> list;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main); 
        File file = new File(Environment.getExternalStorageDirectory()
            + File.separator
            + "mymusic" //folder name
        );
        if (!file.exists()) {
            file.mkdirs();
        }
        ListView lv = (ListView) findViewById(R.id.listview1);
        list = getSD();
        lv.setAdapter((ListAdapter) new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list));
        Log.d("LOG", "FIRE !!!! " );  

        lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                // When clicked, show a toast with the TextView text
                Toast.makeText(Testopen.this,"clicked an item", Toast.LENGTH_LONG).show();

                Intent intent = new Intent(Testopen.this, OpenFileActivity.class);
                startActivity(intent);
            }
        });
    }

    //read from sdcard
    private List<String> getSD() {
        List<String> item = new ArrayList<String>();
        File f = new File("/sdcard/download");
        File[] files = f.listFiles();

        for(int i = 0; i < files.length; i++) {
            File file = files[i];
            //take the file name only
            long size = file.length()/1024;

            String myfile = file.getPath().substring(file.getPath().lastIndexOf("/")+1,file.getPath().length()).toLowerCase(); 
            //item.add(myfile);
            item.add(myfile+"             "+"Size:"+size+" KB");

            // Log.d("LOG", "fs "+file.length());
            //item.add(file.length());
        }
        return item;
    }   
}
Run Code Online (Sandbox Code Playgroud)