Guys, I need an android application that can be configured by the user. In java, we are using properties file to configure the applications. Any idea about the same in android..
Thanks in advance
I can guess you need preferences.
You can use SharedPreferences or PreferenceActivity (this article will be a good start).
If you want your files that can beaccessed from outside you should have some xml file in your resource folder or you can also sed a file along with your application and store iton external memory as andorid do not provide you feature of acessing private datas, toa ccess private datas u need content providers that will be overhead as in your case..
hence better, u bundle a xml file along with you app, which at deployment need to save a copy at sd card and once its there everytime you should check for that file..
this way user will be able to chnge the contents without even running the program, also other application will be able to access youir file
hope this helps
Related
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.
I have a flash application, lets call it "bee". I want Bee to save its data into an xml file in the specific directory. Check if the xml file and the directory exists or not, if exists then update it, if not then create the new one.
My .xml look like this :
<Achievement>
<Coins>800</Coins>
</Achievement>
I want to deploy bee to Android Device. Is it possible ? how to do that ? I would like some suggestions as to how to start the task.
Any code snippets and links will be helpful ...
Thank You
In android we can store data in many ways, The simpler method is SharedPreference,
By using this method you can store data as Xml format,But If you deploy your flash application to android device no need of using any conventional android methods for data storage, You can use the same method followed in flash files.
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.
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
I have created an android app that calculates the numerical values of word, and gives you a list of other words with the same numerical value. The way I have been doing it, is storring the words and value in a .properties file. Ie. A line from a .proprties file called "myWords" will have something like: 61=you, then I just use a get() method to call it,
ie. String myString = ResourseBundle.get("myWords").get("61"); would return the string "you". Is there a better way to do this? My guess is that this is not the proper use of a .properties file, and I was wondering if there was another way to do this correctly. I want to include the file in assets folder of the app, and from my limited understanding of sqlite, you can create a file within android, but you can't just include a file in the assets folder, and then read it. So that said, is there some other type of file that I should use, or was I wrong about sqlite, or is the .properties file being used correctly?
SQLite is your best bet and is the best way to handle your data on an Android phone, that is why Google bundled it on Android in the first place, to avoid people the pain of dealing with files.
If you follow this Tutorial they will show you how to create your database in your computer and then load it up on your "assets" folder and access it from your Android application.
Hope that helps!
You can use a csv file, read it from the assets folder each time the app starts or only once after installation and then store the values in a database.
Take a look at my answer here on how to read the files included in your app (you would use a csv file instead of a libray, but it's still reading files): Hosting an executable within Android application
Edit: here's another example to read from the assets folder: Image uploaded from the android app space seems corrupted
You can try out database option. Here is an interesting tutorial on how to pre-populate a database and then ship it out in the APK.