For my project, ppl can give an answer to a certain question they get. I perform userAnswer = etUserAnswer.getText().toString().toLowerCase(); on it and then compare it to a value that is stored in the SQL database.
But I was thinking that it is quite annoying for a user if the answer is just almost correct but if he has written 'kk' in a word instead of 'ck'. Therefor I am trying to create a system which checks if the answer is more or less correct and then returns the result of this. I searched the net but don't seem to find anything on this subject. I also don't know if such a system has a certain name in english?
Or.. maybe somebody knows a good tutorial or a good way to get started?
I guess you're looking for the string distance, for which you could e.g. use the Levenshtein Distance. For alternative metrics, see this question
Related
I'm relatively new to android and programming in general and I'm practicing by trying to make an app that emulates what the Contacts/People app does (show my contacts). I've spent some time doing research and I'm having trouble understanding how ContactsContract work.
I'm not understanding how to access the contacts information, for example Emails, Phone numbers and addresses. I know you can get the contact _id or lookup_key (not sure which is better) from the ContactsContract.Contacts but to get all the compiled information for that particular aggregated contact would mean that you have to go through all the raw contacts associated with it. That seems inefficient and complicated. Is there a way to access all that information from one spot for example say a "ContactsContract.Contacts.Data.(Data associated with that aggregated Contact)"?
On a side note, would it be possible to modify the data (i.e adding a new phone number or removing an email) directly into that "ContactsContract.Contacts.Data" table if it exists? I have done little to no research on adding information to contacts so this may actually be really easy and I have no clue, I just thought I'd ask while I'm here.
Simple example of ContactsContract API
Just to let you know some stack overflow users will down mark you or stop your post because you say you not done much looking etc. So be sure to have a look on the net before you ask a question hope this link helps you.
I'm aware that there is another similar question on this topic, but personally I am not satisfied with the accepted answer, so this question also asks for an explanation to justify the preferred method. The accepted answer said that the "recommended practice to use a text field to store dates within SQL lite," but this does not make sense to me. I'm not knowledgeable enough to counter with a more definitive answer, but it is my understanding that strings use more memory and are more computationally more difficult to handle than integers. Would it not be better to use Unix timestamps (stored as integers), instead of text to store dates/time? Is not, what IS the downside to using Unix timestamps, compared to text?
Personally I wouldn't worry all that much. I always use ints with unix timestamps, you're right they'll use less memory. Also they're pretty self explanatory, but only precise to seconds, nothing more. If you need something more precise (milliseconds etc) then you need to get creative.
However storing as plain text is fine, SQLite doesn't have the functionality to store datetime, so the three options suggested at http://www.sqlite.org/datatype3.html#datetime are TEXT, REAL and INT.
Given that these are the ways they actually tell you to store dates and time, and given that there is no official word on which is preferable, I wouldn't worry too much. Choose what you are comfortable with and which suits your needs best.
Phone numbers can be expressed lots of different ways:
555-555-5555
1-555-555-5555
+1-555-555-5555
Are all the same number, just expressed differently. Android's ContactsContract.PhoneLookup class Is designed to solve this problem. I'm about to run this through some tests and post the results, but I figured it would be worth making a question to see if anyone else had some experience with this and knows the answer. I could save a ton of headaches by not needing to filter out the +1 and other extraneous symbols before the number if I can count on this PhoneLookup class to do its job for the users. Can anyone testify in support of it?
Thanks. If I don't hear back from anyone I will run some tests and let you know how it goes.
Wrote a quick application to test this, found that the class can account for every variation of a phone number:
+15555555
15555555
5555555
Including hyphens (-) as well. Hope this save someone time in the future.
so I am starting to learn how to develop Android Applications. I have experience with Java and C# from school, and I would say that while I am not a pro, I definitely have a fairly good handle on Object Oriented Programming.
So one thing I don't understand about Android is resources. For example, let's say I have a TextView in my GUI. Why do I have to define a string "Hello," then make the value that string called "Hello" = "hello?" I don't understand why the software development kit doesn't just let users make that string value "hello," and be done with it. What is the purpose of storing numbers and strings and stuff into resources? I know that there must be a solid explanation for this, but I just don't know what.
Also, I am experimenting with an Addition program (where I prompt the user with a randomized math problem, and they can input their answer, and my program will check if it is right or wrong, and restart). So I have a TextView for the problem (i.e., 1 + 1). When I create the TextView, I had to create a problemString in the resources, and then assign the problem TextView to the problemString. However, in my program, when the user has gotten the math problem right or wrong, I write over the problem with a new problem by simply changing the text of the textview. In no way do I interact with the problemString from the resources. And this works. So again, my question is, what is the purpose of having application resources and what role do they play in an application.
Also, how do I access, write over, and do stuff with the application resources.
Sorry that this is a really long question, but I really think Android dev. is really cool, and I am very eager to learn. Any help is APPRECIATED! xD
Thanks!
Imagine your application with a thousand different strings to display to a user. If you need to change 30 of them, do you want to dig through all your code, or one file?
Also localization is another reason for having different sets of string resources, as well as other resources, specific to a locale. Take the above scenario, a thousand different strings, AND three different languages. How would you handle that? Three different version programs? No.
I'm trying to find a way of checking if the user is in the US, and do it somehow that it's instant. This means no GPS, and no internet.
I have a few ideas, but they're not as accurate as I'd want, so maybe someone here has some tricks up his/her sleeves.
Thanks!
I've just been looking at http://developer.android.com/guide/topics/resources/providing-resources.html and on table 2 there's some resource qualifiers for 'MCC and MNC' and 'Language and region'.
What about defining some resource, say a string indicating the country code, then setting up a different one for each country you are interested in.
You could then look at the string to see what country you are in. I guess you'd need a bit of experimentation to see what works best, but it might work :-)