开发者

Querying Android db for specific piece of data

开发者 https://www.devze.com 2023-01-15 09:39 出处:网络
I\'m creating a method that will see if a column in a database row is populated; and if so, it returns the varchar in that row, else it calls a web service to return that data.

I'm creating a method that will see if a column in a database row is populated; and if so, it returns the varchar in that row, else it calls a web service to return that data.

My question is: What is the standard way of simply selecting a column with Android? (select mycolumn from mytable where _id = x;)

I've created a ContentProvider around my database. Should I just call开发者_运维问答 'query' directly? Note: This method is in a Service


you just need to mess with the selection argument in the query

String selection = MyDatabaseConstants.ID " = " + String.valueOf(x);
Cursor c = getContentResolver().query(MyDatabaseConstants.Content_URI,MyDatabaseConstants.Proj, selection,null,null,null);
0

精彩评论

暂无评论...
验证码 换一张
取 消