I want to convert a String
Array to String
so that later on while retrieving I can parse String
to String[]
with the help of (,
) separator.
String [] ------------> String
//and later
String ---------------> String[]
Can someone guide on how to do this?
for (int i = 0; i <= count; i++) {
Log.d(TAG, "arrayData == " +arrayData[i]);
// Joining:
String joined = String.join(",", arrayData);
//This will give error "The method join(String, String[]) is undefined for the type String"
}
You can use String.join
StringBuilder
and String.split
:
// Joining:String joined = String.join(",", stringArr);StringBuilder buffer = new StringBuilder(); for (String each : stringArr) buffer.append(",").append(each); String joined = buffer.deleteCharAt(0).toString(); // Splitting: String[] splitted = joined.split(",");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With