1,105,644 Community Members

Creating Variables in Android

Member Avatar
Wolxhound90
Junior Poster in Training
61 posts since Mar 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Hey guys,

I'm just starting out with Android development using Eclipse. The only programming language that I've used a lot before is VB.NET, so I'm just wondering, is it possible to create variables which you can then add to over the course of the session?

I'm particularly thinking of strings because I want to create an app that will be used so that users can go through a series of options to build up an SQL query, then send this query to a remote server and return the results.

Can it be done similar to VB.NET? Or is it completely different?

Any help at all would be very much appreciated.

Thanks in advance :)

Member Avatar
peter_budo
Code tags enforcer
7,939 posts since Dec 2004
Reputation Points: 2,502 [?]
Q&As Helped to Solve: 1,028 [?]
Skill Endorsements: 66 [?]
Moderator
Featured
 
0
 

Can it be done similar to VB.NET? Or is it completely different?
>> I wouldn't know never used VB. For the rest it just a variable, how you handle it and interact with it is up to you. To build it you can consider StringBuilder instead of some concatenation often see from beginners

Member Avatar
Wolxhound90
Junior Poster in Training
61 posts since Mar 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Ok, well in VB.NET, for example, to declare the variable I would do:

Dim strQuery as String = "SELECT "

and then as I was going through the options I would do something along the lines of:

strQuery += txtFirstAttribute.Text

which would take the text from the textbox "txtFirstAttribute" and add it onto the end of the string.

From reading that link I get the impression that it's something along the lines of:

new StringBuilder("SELECT ").append(txtFirstAttribute)

Would that work in the same way?

Thanks for your reply, sorry if I'm asking some stupid questions :P

Member Avatar
peter_budo
Code tags enforcer
7,939 posts since Dec 2004
Reputation Points: 2,502 [?]
Q&As Helped to Solve: 1,028 [?]
Skill Endorsements: 66 [?]
Moderator
Featured
 
1
 

Yes exactly StringBuilder is better way then what you showed in VB which is also possible in Java/Android

Member Avatar
Wolxhound90
Junior Poster in Training
61 posts since Mar 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Ah, thank you very much :)

Question Answered as of 2 Years Ago by peter_budo
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: