User
User

Reputation: 509

having unneeded spaces between lines

I am writing my data in a database and getting it in android to set it in a textview but when I write for example: "hello, how are you?"

which means each line on a row if the row in the phone completes I get an extra line space and I don't want this need to remove it how can I do that? thanks.

EDIT: how can I place a line space in an arabic database: I added \n didn't work "\n" didn't work '\n' didn't work!! any ideas? even if the database wasn't arabic that didn't work so can I place the \n in the database in a way that the android program takes it as a line space?

Edit2 Is there any other method? other than the one that I've mentioned in my answer? thanks.

Upvotes: 0

Views: 77

Answers (2)

User
User

Reputation: 509

so what I did is that I've added the word "line space" in my database and I added in my android code:

String input = //here I take the cde from cursor; input = input.replace("line space", "\n");

and it worked perfectly but is there another way?

Upvotes: 0

Jony-Y
Jony-Y

Reputation: 1579

check to see if you insert to your DB with that extra line. showing more code would help us understand whats causing your issue...

but if you want to brute force it you could always use substring() for each or your elements or

 `String  input = EditTextinput.getText().toString();
                      input = input.replace(" ", "");`

but like @Nitin Sethi said more code especially the entry to your DB would give us a better understanding of what's going on

Upvotes: 1

Related Questions