user1167473
user1167473

Reputation: 21

Problems reading file from ddms in android?

The file i want to open is located in the file:

/data/data/MY_PACKAGE/files/samplefile.txt

I have pulled the file from ddms and the desired content is in it

I just want to get the text file in order to parse it..

I tried the following:

File sdcard = Environment.getExternalStorageDirectory();
//Get the text file
File xmlFile = new File(sdcard,"samplefile.txt");

but no joy...

Thanks in advance!!

Upvotes: 1

Views: 586

Answers (2)

dymmeh
dymmeh

Reputation: 22306

In order to open a file stored within your applications private directory you must use openFileInput(String fileName). This will return a FileInputStream that you can then work with.

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006724

Use getFilesDir(), not Environment.getExternalStorageDirectory(), to get at the root of internal storage, where your file resides.

Upvotes: 1

Related Questions