adrian adrian - 1 year ago 124
Android Question

concatenate two strings

Let's say I have a string obtained from a cursor,this way:

String name = cursor.getString(numcol);

and another String like this one:

String dest=cursor.getString(cursor.getColumnIndexOrThrow(db.KEY_DESTINATIE));

If finally I wanna obtain a String from the two of them,something like:

name - dest

Let say if name=Malmo and dest=Copenhagen

How could I finally obtain Malmo-Copenhagen???

Because android won't let me write :


Answer Source

The best way in my eyes is to use the concat() method provided by the String class itself.

The useage would, in your case, look like this:

String myConcatedString = cursor.getString(numcol).concat('-').
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download