InputStream is = new InputStream("/sdcard/your_file");
--- 09年3月17日,周二, AlexNguyen <[email protected]> 写道:
发件人: AlexNguyen <[email protected]>
主题: [android-developers] Re: How to read the file in sdcard?
收件人: "Android Developers" <[email protected]>
日期: 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---