Simple editor for Android Permissions File - android

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

Related

Opening Files from a String Path with Android NDK

I've been going over the Android file access documentation lately, but I seem to be unable to figure out how to actually open a file given as a string containing the path to the file I'd like to open.
What I (eventually) want to accomplish is something like this:
The user selects a specific kind of text file using Intents, receiving a URI to the file. From this I derive the path (getPath()) and pass this string to the native C++ code.
The native C++ opens the file from the string, parsing the content.
Perform some actual work with the above.
From what I've found so far, it seems like it is no longer possible to open files this way (as of SDK version 26 at least):
A hard-coded path to a file I know exists gives me permission denied.
The path itself received from getPath() triggers a No such file or directory error.
One workaround called for opening the file on the Java side using the ContentResolver, and then passing the file descriptor to the native side. This works, but it's problematic: the files can contain references to other files to be opened ("include files") making such a solution of limited use.
Just to make things clear, these files reside locally on the "USB" partition of the Android system, unrelated to the app itself. Not as resources/assets to the APK or anything similar which other questions of this kind seem to require.
In summary, I guess the question is this: Is it possible to open a file, and possibly any other files it refers to, given a path from the Java side of the application? Is there any requirements for doing this, such as requesting the correct permissions for folders or something similar?
As of Android 6.0 (API level 23) you need to request permissions every time your app starts for "dangerous actions" such as accessing the filesystem or reading contacts. The linked pages already have a snippet of code you can copy.
On older phones requesting permissions in the manifest was sufficient, but the target SDK version was recenly upped to 8.0 (=26). If you want to support devices pre-6.0, the Android compatibility library will allow you to call the same API.

Cordova/Phonegap - Where do I put a data file I want to read?

I've been driving myself crazy trying to find the answer to a seemingly easy question.
I am trying to create my first app using Cordova. I want to bundle a text file with my app that can be read when the app starts up.
Where do I put this file?
dataDirectory seems like a good place, but where is it? Documentation says /data/data/<app-id>/files but where are those data directories? Do I create them?
Update 1: Ok, I think I've figured out that dataDirectory should be pretty much just where the path says it should be, at the root of the file system. But the directory doesn't appear to be created automatically and I don't know how to package a file - a JSON file, for instance - and place it in that directory.
Essentially you do not need to create these directories. Those are created once your app is installed by the Android itself.
A typical way to get this done would be that you could first off add those files in your app's assets directory and then at runtime you can copy those file wherever you want.
There is a repository on Githup which provide a similar functionality.

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

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

How to modify android string.xml or our own xml file runtime

My requirement is I need to modify client configuration information into one values/client_configuration.xml at runtime. I Google it, couldn't resolve issue. I don't want to keep in sharedPreference. Because this application already developed need to do some modification only. So are there any ways to change file?
please guide me.
Thanks
You cannot change any files that are included with the application as it's distributed. What you can do is copy an XML file from inside you assets folder, for example, to the internal storage and then use it from there. You can modify the file on local storage as necessary. Or use a sqlite database.
You didn't provide any context about what it is you really need to do, but it sounds like you don't have a full understanding of how apps utilise storage. I strongly suggest you read Storage Options sections of the Android documentation.

Android - Encrypting/Protecting SD Card Content

I have an application which writes and reads from a specific file on the SD card.
What i would like is a way to encrypt the whole SD card or a minimum of That specific folder. So if the phone is stolen no one can read the content of that folder.
However, i also want the application to still be able to interact with the folder and the password isn't required until someone looks at the folder specifically (using astro etc) or inserts it into a PC to view.
Is this possible? thanks
You'll need to do this manually, look into javax.crypto for getting the crypto bit done relatively painlessly.
This won't be possible with an ordinary (unmodified) android system (I assume).
If you are talking about your own app - you could implement your own file level encryption in your application.
For everything else, I'd say you need to modify android to include some kind of encrypted file system and the relevant UI for it.

Categories

Resources