Jo Jo Roid Jo Jo Roid - 1 year ago 129
Java Question

How can I get previous value java?

I have tow

Spinner dropDown
on my
when user select each of spinner I'll take an id from
,and I have a class that I send these Ids to it class .


public class getID {
private String tagID = "105358";

public getID tagID(String tagID) {

this.tagID += "," + tagID;

return this;
public URL build() throws MalformedURLException {
return new URL(

Problem :

But when I select an item on second spinner I lost the first Value of the first spinner .

I send my value to class with this code:

URL url = new getID(Const.URLMedia)

For example when I select an item on first spinner(for exam I send 10 value) in other class I see :


when I select an Item on second spinner(for exam I send 85 value) in other class I see :


But I need to :


Answer Source

Seems like you are creating a new instance of getID

URL url = new getID(Const.URLMedia)

so when you select the first spinner you get 105358,10 and when you select second, your code will again create new instance of getID and you get 105358,5 so simply create a singe getID instance instead of creating new every time.

class Activity ..{
getID  url;

          oncreate (Bundle saveinstance){
          url=new getID();

Now simple appends the value

URL url = obj.tagID(StringValue).build(); 

plus i can't see any constructor for this getID(Const.URLMedia),seems like missing.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download