Virtual Table Problem

by cyntacks » Mon, 10 Nov 2008 20:42:52 GMT

Sponsored Links
 Hi All,

I Am experiencing a strange issue regarding the joining of a SQLite3
Virtual Table with a "regular" table. MY result allways pull back 0
records, but if i run the same sql on the 2 reular tables it pulls
back all records. After hours or debugging this I am starting to
believe I may not fully comprehend what this sql does on the backend.
This returns now rows:

SELECT, o.year
JOIN SOME_OTHER o ON o.test_id = v._id

Now, the STRANGE part of all this is using the "regular" table which
was used to create the virtual table works fine and BOTH the "test_id"
and "_id' values ARE in each table:

SELECT, o.year
JOIN SOME_OTHER o ON o.test_id = n._id

What am I missing, is it possible to join a Vitual and "regular"
table, sqlite3 doc claims it is, but..

Thanks for the help,



Virtual Table Problem

by cyntacks » Mon, 10 Nov 2008 22:40:33 GMT

 GOT IT!!! This was driving me nuts for HOURS!!!!

Long story short, SQLite does not validate fields, that is, you can
stick an INTEGER into a VARCHAR. My code was inserting an INTEGER into
a VARCHAR "assuming" it would be cast into a VARCHAR but in actuality
no conversion takes place, it was just being treated as an INTEGER,
thus my join failed becuase SQLite was seeing the entry as in INTEGER!

Wow, that took WAY too long to figure out...


Sponsored Links

Virtual Table Problem

by Mark Murphy » Mon, 10 Nov 2008 22:47:38 GMT


That's a SQLite-ism. Types expressed in table schemas are hints more so 
than mandates.

Mark Murphy (a Commons Guy) 

Android Training on the Ranch! -- Mar 16-20, 2009 


Other Threads

1. ImageButton caching images when using Uri

I'm seeing some caching problems when using an ImageButton with a Uri
and I'm not sure if there's a flag that needs set somewhere or not.

I'm using the button to add an icon to an item in one of my
applications, exactly like it's being used for the Contact application
(which I don't think the source is available for).  I'm using the CROP
trick seen in this application:

Specifically, I'm calling the image picker and then the crop like so:

protected OnClickListener cmdIconListener = new OnClickListener() {
    // @Override
        public void onClick(View arg0) {
            Intent i = new
            startActivityForResult(i, AddTea.ADD_ICON);

protected void onActivityResult(int requestCode, int resultCode,
Intent data){
    // See which child activity is calling us back.
    switch (requestCode) {
    case AddTea.ADD_ICON:
        // This is the standard resultCode that is sent back if the
        // activity crashed or didn't doesn't supply an explicit
        if (resultCode != RESULT_CANCELED){
             Intent i = new Intent("");
             Log.d(TAG, "path: " + data.getData().getPath());
             i.putExtra("noFaceDetection", true);
             i.putExtra("outputX", iconWidth);
             i.putExtra("outputY", iconHeight);
             i.putExtra("aspectX", iconWidth);
             i.putExtra("aspectY", iconHeight);
             i.putExtra("scale", true);

             if(iconUri == null){
                 ContentValues values = new ContentValues();
values.put(android.provider.MediaStore.Images.Media.TITLE, name + "
"STeaP Tea Timer Icons");
                 iconUri =
              i.putExtra("output", Uri.parse(iconUri));
              startActivityForResult(i, CROP_ICON);
    case AddTea.CROP_ICON:
        if (resultCode != RESULT_CANCELED){
        Log.d(TAG, "Data String: " + iconUri);

protected void showIconButton(String iconUri){
    if(iconUri != null){
        ImageButton iconField = (ImageButton)
        Log.d(TAG, "iconUri: " + iconUri);

So if the item doesn't have an icon, set one in the ContentProvider
and save the iconUri.  If it does, just overwrite it with the new
cropped image.

This works fine if the item never had an icon.  It shows in the
ImageButton when the Activity returns.  However, if the item already
had an icon, my Activity still shows the old icon, even though it was
overwritten.  It seems that if the ImageButton gets the same Uri back,
even if I wrote a new image to it, it doesn't redraw, even if I tell
it to invalidate().  If I relaunch my Activity, the new image shows up
just like I expected.  Funny enough, the Pictures application doesn't
see any images I created until I restart the emulator, which also
doesn't seem ideal!

So, is there anyway to handle this caching of the Uri?  I seems like
the ContentProvider should be doing this when I write a new image to
it, but it doesn't seem to be.  Also, before anyone suggests, I tried
deleteing the entry in the ContentProvider and making a new one and
that seems to partially work.  It partilly works because, if the Uri
we get back it new, the view does refresh with this new Uri.  However,
if the icon was the last picture to be saved to the ContentProvider,
say item 10, then the ContentProvider will delete item 10 and the
reuses 10 as the next id!  So I'm back where I started and the
ImageButton shows the old icon.

Any help in kicking the ContentProvider of ImageButton into shape
would be appreciated.

2. Algorithm writen in C

Hello buddies!!
I'm involved in a biometric project. I need to write an app for
Android that must use an algorithm writen in C language. This C code
is very complex and for this reason translating this code into java is
not an option. The idea is to develop the main application in java
code and this would "call" to the algorithm somehow, so the algorithm
could return a value for the main app. I know there are some libs
writen in C/C++ and I'm wondering if I could do so for my project,
write my own lib and call it from the main app. But I don't know if it
is possible, how to do it, how to compile my C code for Android and so
To help the algorithm is writen in C and is compiled for Linux.
Could anyone lead me through the darkness?
Thanks mates.


3. Porting iPhone application to Google Phone using Android

4. Connect to an online SQL database

5. Important Announcement: Handango Android Catalog

6. Application for turning off mobile ?

7. Android Emulator and the Tilt Sensors