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 display images from Firebase storage when viewing an ionic app on an Android phone?
Unable to view Image
Shortcut to open library method/object description
errors while launching the emulator in eclipse
Check box issue in Recycler View
Remote lab for Huawei's mate 9 and 8
Android image from photo gallery
How to stream live video from DJI Professional 3 camera?
How to change the WindowManager.LayoutParams' type programmatically?
How to get user data with SharedPreferences from RegisterActivity
Adjust Resize not working on WebView popups in android?
How to inject custom css in wbeview
How to set load more on top of RealmRecyclerView instead of bottom?
Android Product Filter approach
Android Studio: MapView or MapFragment [duplicate]
android canvas draw text in the triangle

Categories

HOME
jpa
ng-idle
merge
fpga
powerpoint
3d
seo
google-cloud-functions
visual-studio-emulator
regular-language
babeljs
boto3
jquery-ui-sortable
vimdiff
pega
selenium-ide
comsol
renjin
android-intent
do-while
linear-algebra
searchview
aws-sdk
smartclient
shortest-path
solrcloud
googlebot
gulp-watch
gmock
perlbrew
testcomplete
constexpr
send
complex-numbers
cart
autolisp
rselenium
biztalk-rule-engine
activexobject
sharding
fiware-cygnus
servicestack-text
latitude-longitude
openproject
graphhopper
sessionstorage
railstutorial.org
mcustomscrollbar
outputcache
http-request
xmldocument
jboss-4.2.x
magento-2.0.7
globalize
vugen
azure-cli
oracleclient
skin
arules
universal-analytics
redistributable
actor-platform
freepbx
kango-framework
java-money
atoi
amiga
mirror
cwrsync
entity-framework-4.3
at-job
browserify-shim
spy++
named-parameters
live555
spring-remoting
ecslidingviewcontroller
chart-director
fb.ui
wcf-configuration
correlated-subquery
httponly
usertype
hibernateexception
pinch
fsevents
xcelsius
mysql-error-1205
jqote
creole
massive
ie-compatibility-mode
application-verifier
qtabbar
int64

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App