I have created an array list from a database column and I want to strip out the square brackets and display each element in a new line or spaced out. I’m using string builder to try and do this, the issue with this code is that it adds all the elements together in the string. Can anyone help me with this?
Here is my code :
Cursor cursor2 = data.IngredientfetchRows(ID);
startManagingCursor(cursor2);
//cursor2.moveToFirst();
ArrayList<String> al = new ArrayList<String>();
cursor2.moveToFirst();
while(!cursor2.isAfterLast()) {
// Log.d("", "" + cursor.getString(cursor
// .getColumnIndex(ProfileDbAdapter.KEY_PROFILE_NAME)));
String mIngredientName = cursor2.getString(1);
al.add(mIngredientName);
cursor2.moveToNext();
}
StringBuilder builder = new StringBuilder();
for (String value : al) {
builder.append(value);
}
String text = builder.toString();
Speech.setText(text);
data.close();
// + " " + cursor.getString(2) + "" + cursor.getString(3)
initSpeak();
speakButtons(StartSpeech);
If you don’t mind the newline at the end of the list: