How to keep the spaces at the end and/or at the beginning of a String?

I have to concatenate these two strings from my resource/value files:

<string name="Toast_Memory_GameWon_part1">you found ALL PAIRS ! on </string>
<string name="Toast_Memory_GameWon_part2"> flips !</string>

I do it this way :

String message_all_pairs_found = getString(R.string.Toast_Memory_GameWon_part1)+total_flips+getString(R.string.Toast_Memory_GameWon_part2);

Toast.makeText(this, message_all_pairs_found, 1000).show();

But the spaces at the end of the first string and at the beginning of the second string
have disappeared (when the Toast is shown) …

What should I do ?

I guess the answer is somewhere here in this documentation link

or is it something like using &amp ; for the “&” character ??

16 Answers
16

Leave a Comment