Poojan
Poojan

Reputation: 3332

I want to read a local text file on my computer on an Android Emulator

How can I put that file in userdata.img so that the emulator can read it? Also, how can to specifiy the path of the file in the code? I am using Windows 7.

Upvotes: 2

Views: 2575

Answers (2)

Octavian Helm
Octavian Helm

Reputation: 39605

To push a file onto the emulator or any other rooted device you'd just issue a adb push command.

adb push FILE PATH_ON_DEVICE

In Java to define the path to a file you can simply create a File object with the path set in its constructor.

File file = new File("/path/on/device");

Upvotes: 1

Aleadam
Aleadam

Reputation: 40401

You can use adb to push the file to whatever location you want. Just start the emulator (without any device connected) and type

adb push myfile /mylocation/myfile

Here is the manual page for the commands: http://developer.android.com/guide/developing/tools/adb.html

Alternatively, you can browse the file system using ddms

Upvotes: 1

Related Questions