I have recently created some code which writes just some text to a file called 'config.txt', however; I want to be able to open this textfile and view its contents.
I have navigated to the file through the eclipse file explorer, but found you can't actually open the file from there.
Which commands do I need in order to open this file and view its contents?
I know this question has been asked before, but I have not yet found any commands which do not lead to an error message; or simply nothing happening.
Thanks for any help.
Callum
UPDATE
I think I have just answered my own question.
I did not realise that in the top left of the file explorer window, there is an icon which allows you to pull selected files from the device to your computer.
You'll probably need to download that file form your AVD to your computer via the "pull a file from the device" symbol in the top right corner first.
By the way, I asked a question about working with files in the AVD a few days ago. Unfortunately, I got no answer but there are some links in that question that might help you choose the way you prefer. So if you're interested: https://stackoverflow.com/questions/24013091/avd-android-virtual-device-sd-card-file-management
You could use adb from a command line if you are familiar with that (or willing to learn). :)
adb pull <remote> <local> would get the file similar to what you did with the GUI.
Or open an adb shell and read it from that session: cat <filename>.
Related
I have a rooted android phone where i install an app from outside the play store. and now I cant access play store anymore. I search for solution and found this. But I can't even edit the host file. I use ES file explorer to edit. This are in the host file.
127.0.0.1 localhost
127.124.218.80
android.clients.google.com
mtalk.google.com
My questions is
How to edit the host file?
What can I delete from the host file?(what are the extra lines apart from default in the host file?)
I don't know why people vote down my question. Anyway I ask the same question on another comunity and got the solution. I'am posting the answer for anyone who has the same problem.
Original Answer
Steps:
Go to ES file explorer click menu on the right.
Scroll down to Root Explorer and turn it on, then click again on the Root Explorer it will open up a new menu.
Click mount R/W it will open a new menu.
Turn on the RW option on for the /system.
Go to the host file /system/etc/hosts and edit the file, then saved.
I have just made an application that uses a SQLite database, and I finally managed to export the database file onto the computer without having to root the Android device. The method I am using is mostly from code I found on various Stack Overflow question/answers. I am basically saving the database file to the public Download folder.
When I look on the Android device using a file explorer, I can see the correct SQLite file in the correct folder (Download folder). However, when I open up the same folder in Windows Explorer from my PC, I can not see the file in the exact same folder.
Now here is the strangest part: When I copy or move the file (using the Android device), even if I am copying and/or moving the file TO THE EXACT SAME SPOT, as soon as I have finished doing this the file instantly becomes visible in Windows Explorer.
I do not want the user to have to do this manually every time, so does anyone know of any way to make sure that the file will be visible right away? Thank you in advance!
Things I have tried so far:
Show hidden files and folders in Windows Explorer
Programmatically moving the file to a new folder within the application itself (the move to the new folder works, but the file still remains invisible in Windows Explorer until manually moving/copying the file again)
Searched StackOverflow for similar issues and have been unsuccessful.
And if anyone wants to see some of my code, let me know and I will post it, but I am thinking that this is less to do with my code and more to do with Android/Windows interaction. And this is where I got my move folder function from: stackoverflow.com/questions/4178168/how-to-programmatically-move-copy-and-delete-files-and-directories-on-sd
Thank you!
I had a similar issue and it was not visible in Windows because I hadn't given it a file extension.
Give it a file extension if you haven't already.
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)
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.
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
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:
Press Windows key+R.
Type "cmd", click OK.
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.
Press Enter.
Watch the output.
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.
I am new to android programming so I will be really grateful if someone helps me.
I am trying to implement steganography in android but my problem is I don't know how to insert images in android. Because of which I am getting "No media found". Please help me with this.
I tried
c:> adb push c:\image1.png /sdcard/image1.png
But I get this in the Command Prompt.
failed to copy 'c:\image1.png' to 'sdcard/image1.png' : Read-only file system
I had the same problem, so in case anyone lands on this page here is how I solved it
When creating the emulator device (I use IntelliJ IDEA) - do not forget to move the radio button on SDCard option to the Size option, and specify the needed size, this way a new SDCard will be created and mounted to the emulator. In eclipse there are some command line parameters you can pass (or something else, I am not sure, since I read it only on the stackoverflow).
After that I stopped receiving the "Read-only file system" error, but I tried and tried and tried copying the files to the sdcard using:
adb push image.jpg /sdcard/image.jpg
or
adb push image.jpg /mnt/sdcard/image.jpg
but was receiving "No media found" error in my app or when I went to the gallery.
So I went to Dev Tools on the emulator applications, then to the Media Scanner. It quickly scanned the sdcard, and boom - I finally got to see my images.
Hope this helps :)
The correct directory for my emulator is mnt/sdcard. This works for me:
adb push README mnt/sdcard
Also note that you can explore directories using adb shell ls <path>, which might have tipped you off to the right path.
Edit - apparently sdcard is a symlink to mnt/sdcard and works for me as well. Using a file named image1.png is also working. Maybe there is a problematic file already located at that location for you?
Edit 2 - I think you also need to have the USB mounting option turned off when you use adb to push files. It sounds like you have this on given your comment about the gallery not finding your media.
I'm trying to learn Android internals and I've seen that boot process starts from init.rc file. I would like to know if there is a way to modify it when the emulator is off or it can be changed only while the emulator is up. In this case, I don't find a vi or similar text editor, so I must adb push the new file over the original, is it right?
Can anyone help me to find a way to edit init.rc file?
I know it might be late to answer but anyway:
If you want to replace the init.rc file by pushing a new edited file using adb you should have a root user permission to change the system from read only to read and write.
Another way is to download the source code of android x86 and then edit init.rc as you want then compile the code and build your own image of android x86. In this way you have the changes you did every time you install the image on any virtual machine.