Reading static file data into a String

Quickly share your Android Code Snippets here...

Reading static file data into a String

Postby dkny » Sun Jan 18, 2009 8:51 pm

I read the tutorial thread on this subject but I didn't see reference to the raw folder which seems to be a key. At least for what i was trying to do. Here's what's working at the moment.

//First import the file into a (new) "raw" folder. That will get it into the file
Resources r = this.getResources();
InputStream is = r.openRawResource(R.raw.[resource_identifier]);
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String readString = br.readLine();
tv.setText(readString); //tv is TextView

There may be some importing necessary but nothing out of the ordinary.

Once Poster
Once Poster
Posts: 1
Joined: Sun Jan 18, 2009 8:31 pm


Return to Code Snippets for Android

Who is online

Users browsing this forum: No registered users and 1 guest