Android app, want to write a text file accessible to Eclipse - android

I need to write a text file from my app, when running within or under Eclipse, which
I can then access with a text editor on the development system (windows 7) so I can print it out.
Initially I was hoping to write a file into the RAW directory, because that is directly
accessible inside Eclipse, but I have read that is not possible. I would like to do
something like that though. Run my app, use eclipse to view the written file.
Is there a readily available way to do this,
thank you

Related

Directory for saving/accessing files in Android

I'm currently developing an app in Android Studio for Android TV on a mac. Ultimately I want to load local image files as card images in a VerticalGridFragment where a card id and an image filename have matching numbers. For the sake of prototyping, right now I'm just trying to set up best practices (as a complete novice) with a single 1.jpg file that will appear on every card.
I'm using the included Android TV emulator and assume I shouldn't attempt to use access or make use of any OSX file system. So my two questions are:
While I'm prototyping and trying to get 1.jpg to be the image for
each card, where should I place this file in a manner that I can
access using a file path string for internal storage, such as /root/1.jpg
which I can later change to /root/$.jpg where $ is a dynamic id
associated with each card. This needs to satisfy both the emulator
being able to access the file, a device being able to access the file when the app is finished, and me being able to place files there
from my host os while prototyping.
A follow-on question. When the app is finished I obviously won't be
relying on manually placing image files. Will the solution to the
above also provide a straightforward means of saving images to this
directory on a device?
Thanks.
Ok, I think I've got my head around this now:
Inside Android Studio, there's a Monitor utility in which there's a File Explorer. Using this, you can browse, and save to the directory structure that the emulator's using.
Most importantly, there is a standard assigned directory for apps to save and open from on internal storage. It can be found in the file browser at /data/data/com.applicationname/files/
From any app, it can be referenced for saving to or opening from using getFilesDir(), which answers question 2.

QPython3 on Android read and write txt file

I am writing a little python textbased game on my android phone with qpython3.
Now I want to store the highscores in a txt file but I can't find out how I can realize this. I know how I can do it on windows but it doesn't work on android.
Hope anyone has an idea.
Krowit
After testing on my device, it appears that QPython has blocked write permissions from the application. Here's a way of getting a version which allows for it*:
Download SL4A, and install it. This is what launches the Python script.
Download PY4A, this is the Android version of Python. You can download both 2.x and 3.x from here.
You'll need a text editor now. DroidEdit is my personal favourite, and you can launch a script straight from the app.
Then you can write in your code, save it, and run it!
Of course, there's no real substitute for a real desktop, at least in my opinion, but this is (again, in my opinion) the best setup I've found so far.
*I don't know where the files are saved, but you can read and write from them, wherever the saved file's directory may be.

Does a file operation (move, rename) change last modified field of a file?

What does "lastmodified" describe? Just the file's content or also file system related things like file name and Path?
My interest goes especially for the Android platform. I will store data in my app's directory. A quick test showed, that a Samsung Android device with Android 4.2.2 does not change the date when moving files with the build in file browser.
from my experience it doesnt change it. After such operations I manually do
file.setLastModified(System.currentTimeMillis());

Load External Text File Into Android App Without Using Resources

I have an android application I am developing in Java.
I need it to load a text file so it can read what is in the text file and get values from it.
However, everything I have read so far has been directing me to use resources and package it up with the application.
However this means if I want to change the text file, I have to reinstall the application, which is not what I want.
I need to end up with the .apk file and the .txt file in the same folder on my android phone so I can change the .txt file and the app reads in the text file in its directory.
Can anyone help?
No, you do not want to end up with the .apk and the .txt file in the same folder.
You want to end up with the .txt in some place that's always the same and that you know about.
You can deploy the initial .txt via the ressources (aka: package it and copy it to the sd for example) and later download a new version (or copy something to the device via usb).
Then inside your app check if the file exists and open it with standard Java. There's plenty of source around for that.

Simple editor for Android Permissions File

I am new to Android and Eclipse development, but not new to software development in general.
As my first real project, to get over the learning curve, I am modifying the SDK example soft keyboard.
I would like to add a macro capability. So far so good.
I have created a Permissions file to hold the macro string definitions and store that in the getApplicationInfo().dataDir – which turns out to be something like "/data/data/…". I can write then read back a single key-value pair – so I know the file exists. But, I can't see the file using Astro file manager or an FTP program looking at the Device. I have a feeling I may not have the access permissions to view the directory and I don't have root.
I would have liked to edit the macro definitions in this file on a PC and then save it back to the proper location – that would've been the easy solution. I think my other options are to create a simple key-value parameter by parameter editor or somehow use intents to open the file using some already available text file editor. I am guessing the second option will also encounter the file permissions problem.
A third option would be to store the file in some publicly available directory. I tried using a few "get DIR's", but they required a higher level SDK than I was using – I would like to stay compatible with version 6 and below.
Can somebody offer suggestions on how I can edit the key-value pairs or find a public place to create this file? And, where to look to find an example of how to implement the suggestion?
Thanks much,
Barry.
You can save any data in the SD card. Please read the SDK here, where there is a code snippet which may help you.
Try saving the file on your SD card.
http://androidgps.blogspot.com/2008/09/writing-to-sd-card-in-android.html

Categories

Resources