Updating XML file on Android - android

I am fairly new at developing for Android and was hoping to get some help with something.
First, just a brief idea of what I am trying to achieve.
Within the app I am developing, the user can create a project profile for each new project he starts. I have already created the code to create a new XML file for each new project which is stored on the SD Card.
Now I want to create a list of the various projects on the main screen for the user to select from, but I'm not 100% sure how to go about this. My first thought was to have an XML file called Projects List which lists all the projects that have been created. But I just can't seem to figure out a way to update an XML file every time a new project is created, and this is where I was looking for some help.
Can someone please help me to understand how to update an XML file?
Thanks in advance for any replies.

My first thought was to have an XML file called Projects List which
lists all the projects that have been created.
Instead of doing this, why not simply see how many xml files there were created(corresponding to projects created)? I assume that, now, you're saving those project in a folder created by you on the SD Card so when it's time to show that information to the user simple check your projects folder, see how many there are(get the names, get a reference to those xml files so you could open them on a user action etc) and present them to the user.
This would be a lot simpler then implementing the logic to update a xml each time the user does some changes to the projects, not to mention the case when the user might delete those xml files when your app is not running.

I would do the following.
The user create some projects - and for each project you have an xml file.
You check for all xml files - grab a bit of info from each, and build a ListView :
Android listview example
From here you can create a custom adapter which would do the hard work of working out what information you need from each XML file and then when the user clicks the 'browse projects button' they can see all projects in a listview?

Related

How to update activity_main.xml with file names and results

I am new to android development. My problem is simple. I have got some test_cases files in a folder. I want to read them ,perform some test operations on them and want show the names of files with test results on screen .But i don't know how to do that.Any suggestion will be helpful....

How to create buttons dynamicly based on file/folder structure in android

im new to android and im trying to make a "simple" app.
However i would like to know if, what i have planned, is possible in android.
Basicly it's a crude database reader/navigator.
I made a folder structure in the assets folder with a few directories and *.txt files.
Now the plan is to read/scan the folder structure on startup of the program and dynamicly create buttons labeld based on the folder,- and file names.
The buttons have to link to the files and folders so the user can navigate the folder structure and open a *.txt file and read it. Also the idea is that the buttons reflect the folder structure as it is in the assets folder.
The idea is that the user can easly retrieve info from the app and i can add info to the app trough *.txt files and adjust the structure just by adding/removing directories and files in the assets folder.
i am using android studio but like i already say'd: i am a beginner with programming and would like to know if this is even possible with android.
And if it is: could someone please tell me how i should start this project or link me to some example code on how this could be done?
Thanks in advance.
If i read your idea correctly, what you are trying to achieve is very much possible. I would start looking at the AssetManager class and I believe what you are looking for is the list() command which should give you what you need.
https://developer.android.com/reference/android/content/res/AssetManager.html
You can obtain the AssetManager from everywhere within your app through the Context object which you will find to be everywhere around. ;)
From there on you can build your hierarchy and open files.
There are some useful wizard projects in Android studio, which will basically setup a general structure of an Android App. I would recommend starting with a Single Activity application and move on from there.
It sounds like ListView is something that could be beneficial for you here. ListView allows you to dynamically create buttons, or whatever you need. ListView has the added advantage that you can use an XML file to inform the ListView of how to display the buttons, images or whatever you want to display for each element of the list. There are loads of videos demonstrating how to use ListView, but here is a link to its documentation: https://developer.android.com/guide/topics/ui/layout/listview.html
Also, if you'd like a structured way of learning how to develop apps, I'd recommend the Android courses on Udacity to help you out.
Best of luck!

Android Multiple File Selector/Chooser Dialog

I have been scouring the internet for a simple easy to implement Android file chooser dialog that also has the option of selecting multiple files and returning a uri or string array with all the files selected.
Currently I use aFileChooser on github and it is according to me better than android-file-dialog. But neither address the issue of passing multiple files.
I am only an intermediate android developer but I think this would be something not so hard to implement by a pro.
I have looked at the code of aFileChooser and I think adding a check box to the file item would be the way to go but as far as code is concerned i am clueless and the developer seems he's not really gonna work on it in the foreseeable future
So in short im requesting for help to either add the select multiple files option to aFileChooser via the github or here, or maybe suggest to me a better dialog that does what i want.
I don't know any file chooser you could use, but I can show you how I made my own long time ago. It's actually pretty ugly, but it does what you ask for. You can select multiple files and an ArrayList<File> is returned via Intent.
So you could use it as an example of how to do it, and implement it yourself, if you really need it to (I wouldn't recommend you to use mine as it is now).
Here are the links to GitHub:
FileSelectionActivity.
Used layout file for the FileSelectionActivity.
MainActivity, on line 225 the FileSelectionActivity is started.
Below there's a screenshot of FileSelectionActivity, as I said, ugly.
"Go Up" goes to a higher level of the file hierarchy, there are two ListViews, one for directories and one for files. The files have checkboxes. When the share button is pressed, each item in the second ListView is checked to see if the checkbox is active or not. That's line 71 of the FileSelectionActivity file.
Anyways, I hope this helps you make your own file selector, or something.
Thank's to the answer above, I've made a simple library that addresses the concern. It not only passes an array of file paths but you can also use to select a folder.
It has thumbnails for image files
auto scrolls to last scroll position
will soon have language support for several locales
Here it is: https://github.com/tapaulo/Android-Multiple-file-Selector-Dialog

new Intent loading wrong xml files

I noticed today in one of my apps that when I loaded a new Intent for a certain few classes(these classes are determined from the click of an object on a Spinner), the layouts appear and they are like the original plain layouts I started with in my project, not the ones I updated and changed to make look better.
I checked all my code and everything, there are no xml files for what it's loading(they are old ones that I had used before). I don't understand why these old, non existing xml files are even loading. It should be loading the current ones I have in my project but it doesn't... Can someone help me with this problem? Thanks
If you're using eclipse, you can try doing Project > Clean, and then Refresh your project. This should make sure you are building with the latest resources.

Creating a project to be reused

I'm sure you can help such a newbie like I am.
I created a project in android and I want to use it as a model for next 10 and more apps, just changing the raw sources.
I mean I want to make some products i.e. 10 videocharts about norway, I make one project with the needed activity and resources so each app will differ only for the content value.
I will keep of course the same file name too if needed.
How can I save the project?
Cause I tried to make a new project from resource but I get an error on top of the tab saying Manifest is not present in the folder while manifest is actually there, and I cannot proceed further.
Thank you
ANgelo
This sounds like a place to use an Android library project.

Categories

Resources