Saturday, 15 August 2015

android - Funny(Glitchy) behaviour querying content resolver -


I was trying to do a little experiment with the Android telephony content provider, so I dropped 40 rows in my code To order by order _id and then using the last lines, to get 20 more rows in another cursor, _id & lt; Previous RIID

  Uri Uri = Uri.Parsi ("Content: // MMS-SMS / Conversation"); Cursor cursor = getContentResolver (). Query (Yuri, new string [] {"_ id", "ct_t"}, empty, blank, "_id desc limit 40"); Log D. (Tag, "cursor:" + string.value (cursor_gatecount ())); Cursor.moveToLast (); String lastId = String.valueOf (cursor.getinet (0)); Log D. (Tag, "last cursor id:" + last id); Cursor.close (); Cursor cursor2 = getContentResolver (). Query (Yuri, new string [] {"_ id", "ct_t"}, "_id & lt ;?", new string [] {lastId}, "_id desc limit 20"); Log D. (Tag, "cursor 2:" + string.value (cursor 2.getCount ())); Cursor2.moveToLast (); LastId = string.value (cursor 2.getInt (0)); Log D. (Tag, "last cursor 2 id:", + last id); Cursor2.close ();  

that returns the 0 rows to cursor 2 and crash, while trying to read its 0th column (index overboundes), but the odd part is that

  cursor cursor2 = getContentResolver (). Query (Yuri, new string [] {"_ id", "ct_t"}, "_id & lt ;?", new string [] {lastId}, "_id desc limit 20");  

with

  cursor cursor 2 = getContentResolver (). Query (Yuri, new string [] {"_ id", "ct_t"}, "_id & lt; 653", blank, "_id desc limit 20");  

Where 653 is stored in the previous ID, I get a valid cursor with a count of 20

Can anyone help me understand this What can that be the problem? For the query method in the will be bound as a string

. In the resulting query, they will appear as '653' , even if you think they should appear as 653

SQLite or Java The interface looks at those strange behaviors when comparing different AGC types. We use Oracle, MySchel or any provider / language, where they are inserted in upper types before comparing them. It seems that false belief than Solivite or rather lies rather than the requirement of runtime or compile time.

So, there is no result when the int = str is a part of the code.

Looks good though.


No comments:

Post a Comment