YeshaiB
YeshaiB

Reputation: 155

Android query to extract first word from a field

So I've been dragging with this one for some time now and simply can't find the solutions

Let's say I have a table called NAME with values like John Doe Jane Doe etc.

I just want to pull the first word.... so everything after the first space ' ' will not show I'm pulling the data into a Cursor as it's over 2000 records

Any thoughts on a raw query that will do such a thing? Thanks in advance Yeshai

Upvotes: 0

Views: 389

Answers (1)

blessanm86
blessanm86

Reputation: 31779

You just get the string from db as a string and use something like

String[] strs = dbString.split(" ");

str[0] should be what you need.

Upvotes: 1

Related Questions