android


how to write a where clause in sqlite query to gain the exact value?


hi i have a poem database and i want to search in the poems this is what my code look like now
public ArrayList searchthequeryforme(String inputText) {
// TODO Auto-generated method stub
String[] columns = new String[] { KEY_ROWID, KEY_TEXT, KEY_TITLE };
Cursor c = mydatabase.query(true,TABLE_POEM, columns, KEY_TEXT+" like '%"+inputText+"%'", null, null,
null, null, null);
ArrayList<poem> myarray = new ArrayList<poem>();
for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
poem = new poem(c.getInt(0), c.getString(1), c.getString(2));
myarray.add(poem);
}
return myarray;
}
but in this case if i search for "poem" for example it retrieves the records in which i have "poet" and it comes with a text that actually doesnt have "poem" i want to get the exact records what should my query look like?
That's what the LIKE operator does. To get an exact match, change
KEY_TEXT+" like '%"+inputText+"%'"
to
KEY_TEXT+"='"+inputText+"'";
If you are interested in using framework instead of coding the database access code, then, please look at Active Android (http://www.activeandroid.com/). It has some very nice query access API as you can from examples here: https://github.com/pardom/ActiveAndroid/wiki/Querying-the-database

Related Links

Cordova Capture Video in WebView
AudioManager.isMusicActive() returning false with headset plugged-in
How can I return a value to a HeadlessJSTask?
Android Currency - java.lang.NumberFormatException: For input string: “099 ”
Button inside listview clickable after few seconds
Gradle error :app:processDevDebugManifest FAILED when added <supports-screens>
Running Calabash Android Test in Emulator via Jenkins Pipeline
Android multiple request for real time data
linking against .so files in a .aar file using android gradle experimental
Unity3D Android dont run
I want some help in Reverse Engineering on apk [on hold]
Multiple recyclerview header
Android memory leak in obfuscated classes
Adview Banner at bottom of LinearLayout covers imagebuttons in Android
How to save and restore last Listview index position multiple times?
9png on different screens scales bad

Categories

HOME
sonarqube
phpword
telegram
google-spreadsheet
datastore
themes
apiblueprint
socket.io
pclxl
vscode-extensions
google-apps
rds
why3
gkturnbasedmatch
plink
soci
cfml
nim
bourbon
boost-icl
breadth-first-search
babel
pagespeed
angular-routing
epsilon
short-url
roundup
surveymonkey
motion-detection
exchangewebservices
tizen-tv
sqlpackage
livelink
postback
quickfixj
wacom
papaparse
python-import
verifiable-c
angular-http
drupal-theming
importerror
wc
getchar
wcftestclient
twilio-click-to-call
corruption
page-replacement
qtranslate
truezip
edit
android-testing
java-websocket
rackspace-cloud
usart
autosar
webjars
jquery-jscrollpane
kango-framework
turbo-prolog
sklearn-pandas
html-to-pdf
ellucian-scribe
toast
concept-insights
jnlua
relativelayout
iokit
file-move
wso2greg
dronekit-android
matlab-deployment
diff3
bcache
code-documentation
exceldatareader
rapidsvn
filesplitting
browserify-shim
ghcjs
easyrtc
cocos3d
rickshaw
psr-4
jama
mdichild
inputmismatchexception
mbunit
pclzip
intersect
curb
tree-balancing
os.system
wcf-configuration
iboutlet
u2netdk
update-statement
scrollbars
spread
lalr
visualj#

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App