android


SQLite view and query on Android


I have two tables one to store a task and one to evaluate the task:
create table task(
_id integer primary key autoincrement,
task text not null);
create table eval (
_id integer primary key autoincrement,
taskid integer,
eval integer);
Some data:
INSERT INTO task VALUES (1,"A small job");
INSERT INTO task VALUES (2,"A easy job");
INSERT INTO eval VALUES (1,1,1);
INSERT INTO eval VALUES (2,1,2);
INSERT INTO eval VALUES (3,2,1);
INSERT INTO eval VALUES (4,2,2);
Then a view joining the two tables:
CREATE VIEW status AS
SELECT eval._id AS _id,
eval.taskid AS taskid,
eval.eval AS eval,
task.task
FROM task JOIN eval
ON task._id = eval.taskid;
SQLite Database Browser doesn't support views. What's a good database browser for android development on linux?
Secondly, consider this query: Select the highest evaluation on each task
SELECT s.task, s.eval
FROM status AS s
JOIN (
SELECT task, MAX(eval) AS maxeval
FROM status
GROUP BY task
) AS pm ON s.task = pm.task AND s.eval = pm.maxeval;
Resulting in:
s.task s.eval
A easy job 2
A small job 2
How do I implement this query in an Android app? I've tried to pack it into a Cursor android.database.sqlite.SQLiteDatabase.query method and its siblings without much luck.
Is there a way to just pass the SQL query as a string into the database and get a result set back?
you can use SQLiteManager a firefox add-onn. It is a visual
browser for sqlite database. I am using it and it is very nice.
If you want to learn sqlite syntax, you can use this tutorial.
You can use db.execSQL(sqlCommand) fore update, write and delete
operations. For read operations you can use cursor =
db.rawQuery(sqlQuery, null);, where db is SQLiteDatabase's object.
1) SQLite Browser - http://sqlitebrowser.sourceforge.net/
2) Use SQLiteDatabase.rawQuery(String sql, String[] selectionArgs) where sql is a string with a query
Did you try .execSQL . You can use it like
db.execSQL("CREATE TABLE User (username varchar(5) , pwd varchar(15))");

Related Links

How to create a Google Keep Style RecyclerView child item that has Checkboxes
Fill FirebaseRecyclerAdapter with data from more than one node
Continue playing videoview after interruption
How to Parse a Nested JSON response in Android
Searching Bluetooth Nearby in 6.0.1
Android textview and edit text data passing
How to make content provider visible to all users on tablet
java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions on Android API 15
How to load images from res/drawable-folder in ReactNative-App?
Error inflating class EditText
Realm recycler view/Recycler view adapter causing latency
ClassNotFoundException with FirebaseStorage
On android what alternative can I use to send key inputs to the entire OS
Use Font-face in Android WebView
ActionBar , TabLayout are leaving (unnecessary ) space after become hidden , Gone
Graphhopper Set up android

Categories

HOME
apache-flink
gpu
character-encoding
swt
hessian
fftw
apiblueprint
javacc
newrelic
big-o
pyqt4
crystal-reports-2013
gluon-mobile
crystal-lang
character
special-characters
jsonpath
libc
scrolltop
qsqlquery
package-managers
mvc-mini-profiler
easyphp
babel
mount
ckfinder
tiki-wiki
ms-access-2003
rpgle
iis-express
custom-controls
powershell-ise
utorrent
video-capture
google-earth-engine
dm-script
metawidget
p4merge
android-softkeyboard
android-ibeacon
movilizer
importerror
ntvs
mschart
activeperl
static-cast
yii2-user
edit
otp
libjpeg
pocketsphinx-android
cronexpression
atlas
meteor-packages
reporting-services-2012
iotivity
mta
jodd
i386
eigenvector
http-status-code-401
query-by-example
nupic
phpgrid
jbase
vhosts
dynamics-nav-2016
terracotta
finalbuilder
nsurlsessiondatatask
kubuntu
shopizer
broadband
gamekit
openbabel
android-cookiemanager
viewer
ghcjs
structuremap3
gnumeric
cfcache
getopt
high-resolution
scrypt
workitem
epiceditor
actiondispatch
font-awesome-4.0.0
cascadingdropdown
http-status-code-410
boost-msm
rmiregistry
pinch
update-statement
photolibrary
globals
hbm2java
lxr
purepdf
asynchronous-wcf-call
todos
flvplayback
information-management
image-capture
pnrp

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