I'm writing an Andriod app, and I'd like to see if there is a quick way for this. I don't really want to split the whole string into multiple array elements, as the contents might contain non-English characters.
I've tried to use whereContains("myColumn", ), but it doesn't return any result. Can anyone please shed some light on this?
If you are looking for a SQL query why not use the LIKE
For example
SELECT * FROM your_table_name WHERE your_column_name LIKE '%your_sub_string%';
I hope this helps!
Based on the tags you placed, I assume you are talking about Parse.
Try this:
yourQuery.whereMatches(<yourfield>,<text you are searching>, "im");
See http://www.parse.com/docs/android/api/com/parse/ParseQuery.html#whereMatches(java.lang.String,%20java.lang.String,%20java.lang.String)
Example:
titleQuery.whereMatches("title", "hello", "im");
i - Case insensitive search
m - Search across multiple lines of input
Related
I have an Android application that uses Google Translate API.
Everything works great, including when I tried to translate phrases that include apostrophe like "We've eaten" to Spanish.
However, problems occur when the translation result I should be getting back contains an apostrophe. For example, when I translate a Spanish phrase, "A ver", into English, it returns "Let's see" with a ";" after "9". It seems like whenever I have a phrase that should return an apostrophe, it returns "'" with a ";" after "9". (Not placing ";" after "9" because it gets converted to an apostrophe by stackoverflow).
I can think of a way to solve it. After I get the translation result, I can match the string for ""'" + ";" and replace it with an apostrophe.
However, I don't feel like this is the way I should approach it. It's very unlikely that a user will actually type in "'" as an input for translation, but hard coding a manual conversion like this seems like it might cause problems down the road. I'll love to hear your thoughts on this.
Please let me know how I should fix/approach this issue.
Thank you!
The best solution is to add &format=text to your query.
You are correct hard codding is not solution,
But you can convert this HTML entity back to apostrophe, by Using HTML classes provided already.
Html.fromHtml((String) "Let's see").toString()
Above code will convert any valid HTML entity.
I Hope this is what you are looking for.
Thanks Guillaume. For those using php.
$translation = $translate->translate($stringToTranslate, ['target' => $target, 'format' => 'text']);
Thanks Guillaume. For those using go. (api v3)
req := &translatepb.TranslateTextRequest{
MimeType: "text/plain", // add this line to request
}
I have the following idea:
In German we have four extra letters (ä, ö, ü, ß) and I don't know any other language which has these vocals but I think French people with their accents also know this problem. We have a lot of apps in the Google Play store for cities, bus stations, trains and other stuff like that. Now it is really exhausting that we always have to write these letters if we are on the go. It would be much easier to write Munchen (=München [de] = Munich [en]), Osterreich (Österreich [de] = Austria [en]) or something like Uberwasserstrasse (Überwasserstraße [de] = Over-Water-Street [en]). So my question is now:
A lot of apps show suggestions for our just typed word. I think in the code it is something like this:
String current = editText.getText().toString();
db.lookUp(current); // Of course SQL statement
Can we hook this so that Android thinks that we have typed an ä, ö, ü, ß if we write an a, o, u, ss and the system looks for words with one of these vowels and suggests both? Here I do not want to ask for code - I want to discuss if we are able to write a hack or hook for the Android system. Also, root-rights can be assumed with the solution. I'm looking forward to your ideas.
You could do this the other way around, by "normalizing" typed characters into their related non-diacritical versions. You can use the java.Text.Normalizer class for this. A good snippet can be found in this article:
public static String removeAccents(String text) {
return text == null ? null :
Normalizer.normalize(text, Form.NFD)
.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
}
When applied to "Münich", this returns "Munich". That way, you can use a simple string comparison using these normalized versions.
This wouldn't work for "ß" though. If that's the only special case, you could handle it separately.
What you are looking for is called accent-insensitive collating sequence. SQLite's COLLATE operator can be used to do such searches, but I learned from another post that there might be bugs you'll need to look out for.
I have following data in my db row:
Espresso: 7,00
Double Espresso: 8,00
Ristretto: 7,00
Espresso Machiato: 8,00
Espresso Con Panna: 8,00
I write it on Word, then copy & paste to MySQL editor. When I save it, my IOS and Android apps cannot show the prices aligned because of the tab characters.
What is the best way to do that?
The best way- those 2 things are different data and are in different columns in your database, I would expect (if not, you need to fix your schema). So put the 2 strings in separate TextViews, and align the text view in xml.
First you can split the data from tab character and use formatting like below in java. I believe in objective-c it should be similar.
String ehe = String.format("%-20s : \t %4dTL \n","ehemehe",23);
String ehe2 = String.format("%-20s : \t %4dTL \n","ehemeheadawd",44);
System.out.println(ehe);
System.out.println(ehe2);
Output it produces is
ehemehe : 23TL
ehemeheadawd : 44TL
replace the "/t" chars with "" before you display the text. by using
String.replace("/t","");
Use a fixed-width font if you have precalculated the number of spaces.
i want to create an android application that can search word in sqlite database using approximate string matching.
for example if someone misspelled the word "switch" with " swithc", the sistem will correct the word and show message "did you mean 'switch' ".
its like google that can correct wrong word. how can i do it ?
have a look at this answer
Java: how to find the most probable string in a list of strings?
you can use the way of string matching as you desire. there is also a github project for this at:
https://github.com/northpoint/blur
can any one know about how to add/insert emotions/smiles to text(which ever i typed in my edit text for my notes). i have little confusion about if i want to add these smiles of type .png in to edit text type of string, is it possible? and also i have to save these input into sqlite database. normally i know to store string data taken from edit text.
but along with that text i want to also add smiles symbols where ever my cursor placed and to be store in sqlite data base. and get it back to read.
so guys any ideas, most welcome!
Try to use java (i.e. android) spannable method to implement smiley (i.e.) images for that. You will surely get it, search in google for "how to add images/smiley with java spannable method in android?" you will get good idea.
Reading your question the first thing I can think of is Mapping each image to a sequence of letters, for example :) is smiley.png etc. Now your database also has these smaller representation However while reading from the database you can convert those special character sequences to appropriate image.
For simplicity in seraching those Strings You can wrap them in some less used characters i.e. [ or { or <.