3

When I upload my program to my Android device, it will have a text file on the device. I have created it in the package directory, and I suppose that it will be uploaded to the device when I deploy the package.

How can I find the file path of the text file in order to be able to use it from the application, so I can read from the file?

I tried some simple code: File file=new File("test.txt");

Is this possible and if so, how can it be done?

2
  • stackoverflow.com/questions/8001067/… Commented Nov 23, 2011 at 11:12
  • it will have a text file on the device and you have created it in the package directory? means where you want to put this text file exactly, in assets directory or in sdcard? Commented Nov 23, 2011 at 11:20

1 Answer 1

6

Import your test.txt file in the directory

/mnt/sdcard/

and access it

String youFilePath = Environment.getExternalStorageDirectory().toString()+"/test.txt"
File file=new File(youFilePath);

Hope this will work in your case...

Sign up to request clarification or add additional context in comments.

1 Comment

if i create the file with eclipse in the package directory and install the application to the device how i will be able to access the file, if this is possible?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.