开发者

Android: Content provider access in a service

开发者 https://www.devze.com 2023-03-20 20:34 出处:网络
I am creating an application that is supposed to start a service which should access to a content provider in android and send some data to an external server.开发者_Python百科

I am creating an application that is supposed to start a service which should access to a content provider in android and send some data to an external server.开发者_Python百科

When accessing the content provider, I need to use the managedQuery function, which has to be called in an Activity. How should I address this issue?

I don't know whether to create another Activity class in order to write the Content Provider access method here. How should I send the data to the server, from the Service itself?

Not sure if I explained myself clearly..

Thanks a lot in advance!


I think you need the ContentResolver class:

ContentResolver cr = getContentResolver();
Cursor c = cr.query(uri, projection, selection, selectionArgs, sortOrder);

// do something

c.close();
0

精彩评论

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