Sorry, you need to write like:
FileInputStream is = new FileInputStream("/sdcard/your_file");


--- 09年3月17日,周二, Jiang <webs...@yahoo.cn> 写道:
发件人: Jiang <webs...@yahoo.cn>
主题: 回复: [android-developers] Re: How to read the file in sdcard?
收件人: android-developers@googlegroups.com
日期: 2009,317,周二,5:17下午

InputStream is = new InputStream("/sdcard/your_file");


--- 09年3月17日,周二, AlexNguyen <alexnt...@gmail.com> 写道:
发件人: AlexNguyen <alexnt...@gmail.com>
主题: [android-developers] Re: How to read the file in sdcard?
收件人: "Android Developers" <android-developers@googlegroups.com>
日期: 2009,317,周二,5:15下午


I created the file.java  to read file so I don't know why it's error.
And there's the error: "android.content.res.AssetManager
$AssetInputStream"

public class Test1 extends Activity{
     /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
       
 super.onCreate(savedInstanceState);
        readfilefromlocal(this);
    }
    protected void readfilefromlocal(Context ctx) {

     FileInputStream istream = null;
     TextView tv = new TextView (this);
        try {
          istream = (FileInputStream)ctx.getResources().openRawResource
(R.raw.sample);

             SAXParserFactory spf = SAXParserFactory.newInstance();
             SAXParser sp = spf.newSAXParser();
             XMLReader xr = sp.getXMLReader();
             ExampleHandler myExampleHandler = new ExampleHandler();
             xr.setContentHandler(myExampleHandler);
             xr.parse(new InputSource(istream));

             ParsedExampleDataSet parsedExampleDataSet =
myExampleHandler.getParsedData();
             tv.setText(parsedExampleDataSet.toString1());
        }
        catch (Exception e){
          tv.setText("Error: " + e.getMessage());
        }

        this.setContentView(tv);
    }
}

If I want to modify to read file at sdcard, how must i do?
Thanks,
--Alex


        好玩贺卡等你发,邮箱贺卡全新上线!







      ___________________________________________________________ 
  好玩贺卡等你发,邮箱贺卡全新上线! 
http://card.mail.cn.yahoo.com/
--~--~---------~--~----~------------~-------~--~----~
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