I have to get a part of my content provider query in a String[] format. Currently I use:
String[] selectionArgs = {"",""};
selectionArgs[0] = Integer.toString(routeScheduleID);
selectionArgs[1] = runDate.toString();
But in this case I have an unknown number of elements.
How can I change the number at runtime (or use something like an Array and convert back to String[]. Is this possible?
You can use List<String> to get your data and then get the array out of it:
List<String> lst = new ArrayList<String>();
lst.add(Integer.toString(routeScheduleID);
lst.add(runDate.toString());
lst.add(...);
...
String[] selectionArgs = lst.toArray(new String[lst.size()]);
You can use List for this. A List of Strings like this - List<String> str = new ArrayList<String>();
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