Morgan Hill Morgan Hill - 11 days ago 7
Android Question

How to get RowID from google fusion table

I have been using Google Fusion Tables with App Inventor, so there isn't much info out there other than that Pizza Party Tutorial. I've been looking at SQL solutions and such for the formatting of queries, but I just can't seem to get it right it appears. I am attempting to use the following code:enter image description here

in order to find the rowid of a row in my fusion table. However, whenever I send the query, I get the following error: Attempt to get item number 2 of a list of length 1: (51)
51 is the number I want, yet for some reason it is accessing the index 2 and I am not sure why.

enter image description here

This is the code that runs when I receive a result, but I never get a result because the query is apparently accessing index 2 or something. I tried to change the last line to say index 2, but I still got the same error - there's still an error for saying index 1...

Answer

The FusiontableControl component works asynchronously, which means, you send the query and in the FusiontableControl.GotResult event you receive the result. Therefore the blocks after your SendQuery method do not make much sense...

In the FusiontableControl.GotResult event your result will look like this

rowid
51

Inside that event use the split block to split the result at \n (new line) to get a list and select the 2nd item from the list using the select list item block to get the value 51. You also can add some error handling and check, if the length of the list is > 1 before selecting the 2nd item...

Comments