Movieboy
Movieboy

Reputation: 373

Is there any easier way than HashMap?

so I'm still fairly new to Java and Android programming. I have designed a simple Text Lingo Android app. Everything works well, but I was just wondering if there is an easier way to create my own "dictionary" of words. Currently...my code involves about 80 lines of

HashMap<String> words //new hashMap

words.put("Lol,"laugh out loud");
words.put(someKey, someValue);  //repeat for 80 different words and counting..

I don't know much about databases, although I don't know if that would really make it easier. Just wondering. Thanks.

Upvotes: 0

Views: 83

Answers (2)

Foo
Foo

Reputation: 606

There is no shorter way indeed. Though it is possible to store the data somewhere online in a XML file and load/parse this data only when you need it. you'll have to make a network connection. See this link.

Upvotes: 0

Kieron Papps
Kieron Papps

Reputation: 145

The method you have shown looks pretty easy but time consuming. The only other idea I could have would be if you have the words in a .csv file you could read the file, then split the string on the delimiter (usually a comma) then iterate over the string array.

That's only faster if you already have a file with the words in.

Upvotes: 2

Related Questions