Working with the SQLite-Database - Cursors

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Postby res » Fri Feb 15, 2008 4:46 pm

With m5 you can use rawQuery to execute the plusminus example, the method naming has been changed.
res
Senior Developer
Senior Developer
 
Posts: 146
Joined: Tue Nov 20, 2007 8:14 pm
Location: United States

Top

Postby plusminus » Fri Feb 15, 2008 6:41 pm

Hello res,

yes you are right, I've just seen it to. But for standard-selects it is probably saver, because it internally adds commas and brackets ^^. But rawQuery is probably a bit faster.
res wrote:With m5 you can use rawQuery to execute the plusminus example, the method naming has been changed.


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby Sportsdude11751 » Sat Feb 16, 2008 11:19 pm

man so I've got your source, compiled it and it worked fine. Then after a few compiles later, all I get is an empty white screen instead of the list of 2 names..what's goin on?
Sportsdude11751
Freshman
Freshman
 
Posts: 7
Joined: Wed Jan 30, 2008 4:28 am

Postby plusminus » Sun Feb 17, 2008 1:32 pm

Hello Sportsdude11751,

every run the list should have become larger... (because we were only inserting datasets and never deleting one).

So you changed really nothing :?:

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby Sportsdude11751 » Mon Feb 18, 2008 2:15 am

Yeah, the list did get longer the times I ran it, then it quit working and not giving me any names. So (just to be sure) I re-downloaded the source code and put it into eclipse and still wouldn't function =\
Sportsdude11751
Freshman
Freshman
 
Posts: 7
Joined: Wed Jan 30, 2008 4:28 am

Postby plusminus » Mon Feb 18, 2008 9:45 am

Hello Sportsdude11751,

what happens to the cursor when you debug the code :?:

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Postby Sportsdude11751 » Mon Feb 18, 2008 5:27 pm

I haven't debugged. I only use eclipse for android, so I wasn't aware of a debug option. Where is it at?
Sportsdude11751
Freshman
Freshman
 
Posts: 7
Joined: Wed Jan 30, 2008 4:28 am

Postby res » Mon Feb 18, 2008 5:58 pm

Sportsdude11751 wrote:I haven't debugged. I only use eclipse for android, so I wasn't aware of a debug option. Where is it at?


You can debug via eclipse, next to the run button you'll see a little bug which will run your application in debug mode. You can also access debug mode via "Run" on the toolbar and scrolling down to the debug option.

Secondly you can use logcat via the emulator to capture messages. You need to 'adb shell' into the emulator from the command line then type 'logcat', you'll see all kinds of interesting information. Their are various logcat commands so its best to look at the android documentation.

The best place to start would be http://code.google.com/android/intro/in ... #debugging
res
Senior Developer
Senior Developer
 
Posts: 146
Joined: Tue Nov 20, 2007 8:14 pm
Location: United States

Postby Katharnavas » Tue Feb 19, 2008 5:32 am

What i hope is the database got crashed.. try -wipe -data ?
Katharnavas
Senior Developer
Senior Developer
 
Posts: 100
Joined: Tue Dec 04, 2007 5:57 am
Location: India

Postby plusminus » Tue Feb 19, 2008 4:34 pm

Katharnavas wrote:What i hope is the database got crashed.. try -wipe -data ?


it helps on so much problems :roll:
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby Sportsdude11751 » Wed Feb 20, 2008 5:03 am

Here is some [not all] of what the LogCat generated. I put in bold what I think the problem is. I wasn't sure how to use the -wipe -data, so I put that in the emulator command line, so when I ran the emulator it executed that? I've removed the -wipe -data from the command line and re-ran and still same problem (after restarting eclipse too)

Code: Select all
I/ActivityThread(550): Loading code package web2.help (in web2.help)
D/SystemClock(506): Setting time of day to sec=1203483448
W/SystemClock(506): Unable to set rtc to 1203483448: Invalid argument
D/ActivityThread(550): Performing launch of ActivityRecord{400db2f8 {web2.help/web2.help.AccountManager2}}
D/ActivityThread(505): Installing external provider contacts;call_log: com.google.android.providers.contacts.ContactsProvider
I/ActivityThread(525): Loading code package com.google.android.googleapps (in com.google.process.content)
[b]E/Database(550): Failed to open database file "databases/myCoolDB_2" - unable to open database file
E/Database(550): Failed to open database file "databases/myCoolDB_2" - unable to open database file[/b]
W/ActivityManager(465): activityPaused called for HistoryRecord{40176d70 {com.google.android.home/com.google.android.home.Home}} but currently pausing null
D/Sync(465): received data connection state changed: DISCONNECTED
D/Sync(465): received data connection state changed: DISCONNECTED
D/ActivityThread(525): Creating service com.google.android.googleapps.GoogleLoginService
I/ActivityManager(465): Displayed activity {web2.help/web2.help.AccountManager2}: 2817 ms
I/ActivityManager(465): Done launching {web2.help/web2.help.AccountManager2}: 2863 ms
I/SurfaceFlinger(465): Boot is finished (0 ms)
D/ActivityManager(465): Stopping: HistoryRecord{40176d70 {com.google.android.home/com.google.android.home.Home}}
I/ActivityThread(465): Loading code package android (in null)
I/ARMAssembler(465): generated scanline__00000077:03545404_00000A04_00000000 [ 29 ipp] (51 ins) at [0x176a00:0x176acc] in 273676872 us
I/dalvikvm-heap(506): GC!
W/SurfaceFlinger(465): LayerVector[0x1149a8, counts=(3,3)]: layer (0x1262f8, index=0) not found (not a bug)
I/dalvikvm-gc(506): freed 6054 objects / 383736 bytes
I/dalvikvm-heap(506): Current GC heap soft limit utilization 737/1000 (1.026MB / 1.392MB) (real 2.062MB)
I/dalvikvm-heap(506): GC heap soft limit grew from 1.392MB to 2.052MB
I/ActivityManager(465): Done launching {com.google.android.home/com.google.android.home.Home}: 8118 ms
D/ActivityThread(525): Creating service com.google.android.providers.media.MediaScannerService
D/MediaScannerService(525): start scanning /system/media
I/ActivityThread(525): Loading code package com.google.android.xmppService (in com.google.process.content)
D/TelephonyProvider(506): Setting numeric '310995' to be the current operator
D/Sync(465): received data connection state changed: CONNECTING
D/Sync(465): received data connection state changed: CONNECTING
D/Sync(465): received data connection state changed: CONNECTED
D/MediaScanner(525):  prescan time: 277ms
D/MediaScanner(525):     scan time: 11ms
D/MediaScanner(525): postscan time: 0ms
D/MediaScanner(525):    total time: 288ms
D/MediaScannerService(525): done scanning /system/media
I/ActivityManager(465): Stopping service: {com.google.android.providers.media/com.google.android.providers.media.MediaScannerService}
D/ActivityThread(525): Stopping service com.google.android.providers.media.MediaScannerService@4011be38
[i]
Sportsdude11751
Freshman
Freshman
 
Posts: 7
Joined: Wed Jan 30, 2008 4:28 am

Postby Katharnavas » Wed Feb 20, 2008 5:08 am

Better you post the whole source so that one can replicate the problem and help you !
Katharnavas
Senior Developer
Senior Developer
 
Posts: 100
Joined: Tue Dec 04, 2007 5:57 am
Location: India

Postby res » Wed Feb 20, 2008 7:07 am

If you use -wipe-data you will need to recreate your database, from the error message Android is unable to locate myCoolDB_2.
res
Senior Developer
Senior Developer
 
Posts: 146
Joined: Tue Nov 20, 2007 8:14 pm
Location: United States

Postby Katharnavas » Wed Feb 20, 2008 7:13 am

res wrote:If you use -wipe-data you will need to recreate your database, from the error message Android is unable to locate myCoolDB_2.


Better you check from the command line also whether database , table and any data inside table is available.
Katharnavas
Senior Developer
Senior Developer
 
Posts: 100
Joined: Tue Dec 04, 2007 5:57 am
Location: India

Postby Sportsdude11751 » Wed Feb 20, 2008 7:56 am

The source code I used was plusminus's source. I will copy and paste it next time I can get on that computer.
Even if it can't find the database, in +-'s source he had a create database statement.
Sportsdude11751
Freshman
Freshman
 
Posts: 7
Joined: Wed Jan 30, 2008 4:28 am

Top
PreviousNext

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 6 guests