[Q]How to read particular values from xml - Java for Android App Development

This is a sample
Code:
<?xml version="1.0" encoding="UTF-8"?><class><Student id="10"><firstname>ak</firstname><percentage>96.0</percentage></Student><Student id="1"><firstname>at</firstname><percentage>96.0</percentage></Student><Student id="20"><firstname>t</firstname><percentage>96.0</percentage></Student><Student id="510"><firstname>aepit</firstname><percentage>96.0</percentage></Student><Student id="90"><firstname>apit</firstname><percentage>96.0</percentage></Student><Student id="110"><firstname>pit</firstname><percentage>96.0</percentage></Student></class>
Now i want to print all data of student of particular id.please tell me how to do this.please prefer dom parser
Sent from my GT-S5570 using XDA Premium 4 mobile app

The documentation has a nice sample on this here. You probably just need to replace entry with student.

Related

Need help with code..URGENT

I am building an app for which I need data from device's internal google calendar..how do I fetch and convert the list of events fetched to RSS?..
App is almost ready..please help
Sent from my ST15i using XDA App
Where are you at currently with this? Any completed parts of this, or are you looking for it 'all'?

How do I add a webview element?

I am coding an aggregation app for most of what we check on our smart phones.
I need a page that can display 4 HTML pages at once. I have no idea on even how to add 1 page. Any ideas?
Thanks in advance.
Sent from my HUAWEI-M835 using xda app-developers app
At once? Next to each other or three of some in the background?
For the last one search for the Fragments documentation.
crazy4creationstudios said:
I am coding an aggregation app for most of what we check on our smart phones.
I need a page that can display 4 HTML pages at once. I have no idea on even how to add 1 page. Any ideas?
Thanks in advance.
Sent from my HUAWEI-M835 using xda app-developers app
Click to expand...
Click to collapse
You should probably use fragments with a webview in each one since on smaller devices it would be really hard to read all 4 webviews or if your set on the webviews being on the same screen a table or grid layout would probably be the easiest way to organize them. There is a composite tab in Eclipse and the last entry is a webview.
This is thenewboston tutorial on webviews:
http://www.youtube.com/watch?v=lkadcYQ6SuY

MySQL Database Connectivity

Hey people,
I have a website service that is built upon a MySQL database. I am trying to code an android app for the same, however I am not able to link my app to fetch and throw data at the database?
Can you help me understand the concept better?
My database is set up on a server over the Internet. How can I have my android app fetch data from it directly?
Thanks, in advance
Sent from my HTC Explorer A310e using xda app-developers app
cyberbeast said:
Hey people,
I have a website service that is built upon a MySQL database. I am trying to code an android app for the same, however I am not able to link my app to fetch and throw data at the database?
Can you help me understand the concept better?
My database is set up on a server over the Internet. How can I have my android app fetch data from it directly?
Thanks, in advance
Sent from my HTC Explorer A310e using xda app-developers app
Click to expand...
Click to collapse
I think you have first to create a webpage server side in PHP and you list the content so you can through PHP commands send requests to your db.
xpirt
Thanks for that, xpirt
Is there a way to do that without using an intermediate php script? A more direct method, which can be implemented within the app itself?
The method you explained is what I wanna keep as my last resort.
Sent from my HTC Explorer A310e using xda app-developers app
cyberbeast said:
Thanks for that, xpirt
Is there a way to do that without using an intermediate php script? A more direct method, which can be implemented within the app itself?
The method you explained is what I wanna keep as my last resort.
Sent from my HTC Explorer A310e using xda app-developers app
Click to expand...
Click to collapse
I don't know. I'm a PHP programmer and I know only with this to connect to databases, I'm a newbie in Java so I'm not able to help you
xpirt
Take a look at this link: http://zetcode.com/db/mysqljava/
The one issue that may stop you is if you don't have control over the server OS. Most hosting providers will not let you connect to mysql via internet connections.

Shared preferences and textview

I originally asked this question in Srackoverflow. But I did not get any answers.
I am trying to set a text view number value to shared preferences using a string to get the values. Can anyone help with this?
Sent from my SGH-M919 using XDA Premium 4 mobile app
mistere372002 said:
I am trying to set a text view number value to shared preferences using a string to get the values
Click to expand...
Click to collapse
Could you elaborate on this?
You want to store the text (which is a number) in the textview to shared preferences?
Code:
mPrefs.edit().putInt("my-key", Integer.parse(mTextView.getText().toString())).commit();
That's correct. I forgot to mention that the number could be a decimal also.
Sent from my SGH-M919 using XDA Premium 4 mobile app
Thanks painless, that worked perfectly!
Sent from my SGH-M919 using XDA Premium 4 mobile app
Storing Chronometer time in SharedPreferences
mistere372002 said:
Thanks painless, that worked perfectly!
Sent from my SGH-M919 using XDA Premium 4 mobile app
Click to expand...
Click to collapse
I am actually trying to store the value of a chronometer in SharedPreferences but admittedly I have not worked with SharedPreferences much.
My end goal is to be able to close the Chronometer app and have the chronometer pick up from where it left off when the app is close.
Any help is appreciated.
Code:
chronometer = (Chronometer) findViewById(R.id.Chronometer1);
public void startClick (View view){
chronometer.setBase(SystemClock.elapsedRealtime());
chronometer.start();
Vibrator vib = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
vib.vibrate(100);
}

(Q) Building automated script for Android game

Hello there,
First I will apologize if I'm in the wrong thread, but from what I read that's the place to ask the question I have
To get to the pint:
I would like to write a script for an android game, which will execute certain actions in the game. I'm talking about a strategy game so the script will make attacks in a loot, thus saving enormous amounts of time if I do it by hand.
I've seen a script like that but I can't get my hands on it, so I've decided to look into writing my own.
Here comes the fun part: I'm a total noob in writing any codes , but I'm a fast learner.
So far I've realized that because the game runs on servers, I'll need to open the source code of the game to extract the commands that the game is using for each action. Than compile a script that will execute that same action (sending it to the server) from my behalf (using my account information) and than put this action into a loop for as many times I would like to (think that would be the easiest part compared to everything else)
I would really appreciate it if someone can point me in the right direction as far as what to read and what to use to do all of that.
Thank you Much in advance!
Shlevy
Sent from my SM-N900R4 using XDA Free mobile app
Does anyone have an idea if it's possible to monitor an application in live time to see the code that is being executed when you perform certain actions?!
For example you press a button in the app and on the computer you are able to see exactly the command executed?
Sent from my SM-N900R4 using XDA Free mobile app
Bump...
Does anyone have at least a slightest idea how to do that? Or any general directions?
Thank you
Sent from my SM-N900R4 using XDA Free mobile app
Up
Bump
Come on guys anything is appreciated
Sent from my SM-N900R4 using XDA Free mobile app
Thank you for the reply!
I'm trying to put a script together that will do automated number of hits for me on certain set target. It is a strategy game (not sure if I'm allowed to post the name of the game)
So pretty much it will need to be able to set number of troops, type and how many times to hit the target. Using that info and my user name it will emulate that I'm hitting manually from the game, but it will be much faster because there is no human lag, directly talking to the server of sorts.
Sent from my SM-N900R4 using XDA Free mobile app
Would you mind to elaborate what is OOP.
I'm pretty noob in scripting
Sent from my SM-N900R4 using XDA Free mobile app
shlevy said:
Would you mind to elaborate what is OOP.
I'm pretty noob in scripting
Sent from my SM-N900R4 using XDA Free mobile app
Click to expand...
Click to collapse
OOP means Object-Orientated Programming.
if you want to see what code is being executed etc, maybe you mean debugging?
if so you can use logcat, eclipse or android studio
Here's the link for the debugging guide : forum.xda-developers.com/showthread.php?t=2325164

Categories

Resources