I want to refer to this question , on how to implement the mention feature, but for android.
I want to know how it goes in the database specifically .
I guess the answer was already provided the old post,
Listen to the input. When the user types an @, followed by a character, make a call to an url on your server (/user/lookup/?username=joe for example) that routes to a view which looks up up users beginning with joe. Return it as json and display it in a dropdown.
To make is much simpler, you need to use @
as a keyword that is going to be used for understanding the beginning of a user name .
e.g. user types the following message
... was with @nour at NYC
in Java you can detect the @
using regular expression,
boolean foundMatch = false;
Pattern regex = Pattern.compile("\\b(?:@)\\b");
Matcher regexMatcher = regex.matcher(subjectString);
foundMatch = regexMatcher.find();
This will match if the input string has a @
keyword
Now once you get the @
keyword take all character after @
till you get a white space. In this example nour
should be the result since its starts after @
and ends before a white space
.
In the server part you can the the recognized name as a USER_NAME
,
SELECT * FROM USERS WHERE USER_NAME = "nour";
Of-course the username needs to the unique.
Hope it helps.