Tvd
Tvd

Reputation: 4601

"The application .... has stopped unexceptedly" Reading Files

I have an xml in /data//files/file.xml and another txt file in same location. I am not able to read those files. It throws me error "The application <...> has stopped unexceptedly" with "Force Close" button and the application quits.

Can anyone help me know the cause of it ? I am really stuck up.

Upvotes: 0

Views: 82

Answers (2)

Tvd
Tvd

Reputation: 4601

Thanks Friends,

I found a solution and now could read the file stored in files folder. Thanks a lot for your help and support.

Upvotes: 0

bHaRaTh
bHaRaTh

Reputation: 3514

You cant access Ur data file like that.

follow these steps

  1. Create a folder in res folder with name as raw . and save your XML file in raw folder.

  2. then use

      InputStream inp = Context.getResources().openRawResource(R.raw.datafile);
    

u will get InputStream reference. where u can proceed further with it as u need.

Upvotes: 1

Related Questions