Reputation: 641
I am saving data internally to the phone in Eclipse, and I was told the file that it was saving to was located here. I try to open the file by double-clicking it to see the saved data, but nothing comes up. What am I doing wrong?
I am trying to check that it is saving to the file properly. I am trying to verify that it is saving the text here since I am not sure where else it is saving it.
I have tried pulling it, and saving it to my desktop, but all I get is this error:
Failed to pull selection
(null)
Upvotes: 0
Views: 5325
Reputation: 2778
The DDMS file explorer LOOKS like a windows file explorer, and so you think you should just click on things and drag them around and so on.
Unfortunately, it isn't. It LOOKS like that but it IS NOT that.
From the Using DDMS page we find:
To work with an emulator or device's file system:
In the Devices tab, select the emulator that you want to view the file system for. To copy a file from the device, locate the file in the File Explorer and click the Pull file button. To copy a file to the device, click the Push file button on the File Explorer tab.
Which is to say, you have to use the buttons to copy the file off the phone on to your local filesystem. From there you can read it using all the double clicking and dragging you are used to.
Upvotes: 3
Reputation: 61341
Pulling the file from the device via the File Explorer is the correct way. Not sure why is it failing. Real phone or emulator?
There's another way though. There's a program called ADB in the Android SDK; it's under platform-tools. Run it with the following parameters:
adb shell cat /data/data/com.mypackage/files/textfile.txt
The package name will vary, obviously. This will print the file contents to the standard output.
EDIT:
Type or paste the following line:
C:\android-sdk-windows\platform-tools\adb shell cat /data/data/com.mypackage/files/textfile.txt
replacing the com.mypackage
name with the name of your app's package, which I cannot possibly know. Also replace the path to the Android SDK, if needed.
EDIT2: by the way, are you closing the stream after writing the data? That could be the reason you could not pull the file via the File Explorer.
Upvotes: 0
Reputation: 1501
I'm guessing you viewing the file from the file explorer in the DDMS. Once you located the file there's a couple buttons on the top right corner to pull/push files from the device
Upvotes: 0