Removing newline from string

text.replaceAll(System.getProperty("line.separator"), "");

Check if there is new line at the beginning before you replace and do the same test again:

for(int i=0; cursor.getString("blah").length()-1; i++)
{

   if(cursor.getString("blah").charAt(i)=='\\n')  <-- use the constant for the line separator
    { 
      Log.i("NEW LINE?", "YES, WE HAVE");
    }

}

Or use the .contains("\n"); method:

Check the xml for the width of the textview as well.

Why are you using getString() when you are fetching an integer? Use getInt() and then use Integer.toString(theint) when you are setting the values in a textview.


There is a mistake in your code. Use "\n" instead of "\\n"

String myString = "a string\n with new line"
myString = myString.replaceAll("\n","");
Log.d("myString",myString);