2

I am developing an Android word game like Scrabble. I need to check if the word a user enters is correct (aka is a String entered by a user equal to an existing word).

All that Android seems to offer is a spell-checking api which provides you with some suggestions based on your input. This just seems silly to me because these suggestions are actual words and there seems to be nothing in the api that is able to check if a word exists in it's dictionary.

I understood that there are some other web based solutions for my problem but I can't assume these web-based solutions will work forever and that users have a stable network connection. Also, my game is time based so the only proper solution would be a local one.

So, (how) can I validate a word (String) locally on Android?

inb4 it can't be done properly and wordnik is the best solution for me

Community
  • 1
  • 1
Gijs Stokman
  • 143
  • 8
  • I had a similar project involving an online MMORPG game I helped develope and I used http://www.freescrabbledictionary.com/api/. – Cesar Bielich Aug 13 '15 at 01:07

1 Answers1

1

Load your dictionary into SQLite and use a query to determine if it's valid.

Thom
  • 14,013
  • 25
  • 105
  • 185
  • Well, I need a predefined (and proper) local dictionary based on the current prefered language. Isn't it possible to use the dictionary of your Android device? (excluding all the words you added yourself) – Gijs Stokman May 02 '14 at 12:48
  • 1
    @NightmareKing Although it is likely that you *CAN* use the android native dictionary, I would not recommend using it, as it is not under your direct control. For example imagine if the android native dictionary is different for different versions of the system, then words in one system could be valid while the same words on a different device would be deemed invalid. Or worse, the android dictionary gets deprecated or starts to work differently, suddenly your game is not working anymore. – Ceiling Gecko May 02 '14 at 12:51
  • Right. As a Scrabble player, I can say that you really want your own dictionary. – Thom May 02 '14 at 13:33
  • @Ceiling Gecko Hmm, good call, I never considered that. I guess this means that my best option is to include a dictionary in my project. – Gijs Stokman May 02 '14 at 14:02
  • I agree, bundling your own wordlist / dictionary seems like the best approach. There are a ton of free wordlists available for download if you just search with Google. I don't know any way to access the Android keyboard's dictionary. Requiring a network connection to be able to validate a word also sounds unacceptable to me. – Tobias May 02 '14 at 17:58