android-contentprovider

Which thread runs ContentProvider?

六月ゝ 毕业季﹏ 提交于 2019-12-02 17:14:36
If I call to a ContentProvider from a Activity, which thread is ContentProvider running in? E.g. What happens if the Activity is killed and a query is executing in the ContentProvider? Say that you have a slow network query f.ex. If you mean the normal use case of using a ContentResolver to call a ContentProvider then here is what happens according to the best of my knowledge: I am assuming in this example that your ContentProvider lives in one process and your Activity in another process. If the ContentProvider has not been created then the onCreate() method is called using the "main" thread

How to handle RESTful update of remote server with SyncAdapter

橙三吉。 提交于 2019-12-02 17:13:11
I've watched the Google I/O REST talk and read the slides: http://www.google.com/events/io/2010/sessions/developing-RESTful-android-apps.html I'm still a bit unclear on how to nicely handle, say, an update error thrown by the remote server. I have implemented my own ContentProvider and SyncAdapter. Consider this scenario: Update a user's Contact Details via REST call: Request an update using a ContentResolver. My ContentProvider immediately updates the app's local Sqlite database and requests a Sync (as per recommendations in the Google I/O talk). My SyncAdapter.onPerformSync() is called and

Android Contacts provider get only phone contacts with all emails

南笙酒味 提交于 2019-12-02 16:43:32
I need to get all phone contacts and their email address and photo uri: This is what am doing: private void getContacts() { ContentResolver cr = getContentResolver(); Cursor cur = cr.query(Contacts.CONTENT_URI, null, null, null, Contacts.DISPLAY_NAME); if (cur.getCount() > 0) { while (cur.moveToNext()) { // if // (Integer.parseInt(cur.getString(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) // > 0) { Contact contact = new Contact(); String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID)); Uri uri = getContactPhotoUri(Long.parseLong(id)); // set photoUri

Google IO Rest design pattern, finished ContentProvider and stuck on getting the data from the network

社会主义新天地 提交于 2019-12-02 15:44:26
After watching the very known video on this topic I decided to go with design pattern B. Using a contentprovider with servicehelper. Basically I have the following files: MyProvider MyDatabase Mycontract In the activity I can now get the contentresolver and query the provider. All is working great so far. Now I need to sync my contentprovider to fetch data from my REST API. Thus I need to implement a service helper service and Rest method. Studying the Google IO app has helped me a lot, I'm a novice with Android so it's still hard to figure it out. I see Google uses RemoteHandlers to process

Difference between ContentObserver and DatasetObserver?

China☆狼群 提交于 2019-12-02 15:11:06
What is difference between ContentObserver and DatasetObserver ? When one or another should be used? I get Cursor with single row. I want to be notified about data changes - eg. when row is updated. Which observer class should I register? If you are using a ContentProvider (via ContentResolver or Activity.managedQuery() ) to get your data, simply attach a ContentObserver to your Cursor . The code in onChange() will be called whenever the ContentResolver broadcasts a notification for the Uri associated with your cursor. Cursor myCursor = managedQuery(myUri, projection, where, whereArgs, sortBy)

getContentResolver().openOutputStream(uri) No files supported by provider

回眸只為那壹抹淺笑 提交于 2019-12-02 13:40:26
问题 I want store a file audio in my personal content provider. i save record: Uri uri = getContentResolver().insert(CONTENT_URI, values); OutputStream os = getContentResolver().openOutputStream(uri); but getContentResolver().openOutputStream(uri); throws: 10-13 19:44:53.903: ERROR/TAB(5679): No files supported by provider at content://com.memento.data.provider.MementoProvider/audionotes/6 10-13 19:44:53.903: ERROR/TAB(5679): java.io.FileNotFoundException: No files supported by provider at content

How do I get the file path from the content URI for video files?

谁都会走 提交于 2019-12-02 11:58:37
问题 I want to attach images or video files from the Android storage. When I select a video from the gallery, it returns the content uri path . How do I get the file path with extension from the content URI? I tried following code, but it returns null in lollipop: void pickVideo() { Intent videoIntent = new Intent(Intent.ACTION_GET_CONTENT); videoIntent.setType("video/*"); startActivityForResult(videoIntent, PICK_VIDEO_FILE); } @Override public void onActivityResult(int requestCode, int resultCode

Android code starting from ContentProvider class rather than Main class

旧时模样 提交于 2019-12-02 11:43:17
Yesterday I posted a similar question on why my code started on my content provider class rather than the main class and I've gotten some feedback which I've updated but the problem still remains where the code starts with the ContentProvider class rather than the main class. I've run through the code with debugger and its puzzling why the code starts in the Content Provider and passes back to the main class at the Context stage. I hope to solicit some help here ! The main class is here: public class MedF1 extends Activity { /** Called when the activity is first created. */ @Override public

Android SQLiteException at create

五迷三道 提交于 2019-12-02 10:23:31
first I want to say I'm new at android, so I'm apologizing if the question is to stupid. I'm writting a Content Provider for a SQLite database with two tables. On table is to show a list at a navigation-drawer activity and the second table is to show in a ListFragment. Everytime when I'm starting the app I'm getting an SQLException. 10-07 15:30:33.856 28280-28813/de.schmidt.android.passworttresor E/SQLiteLog: (1) near "table": syntax error 10-07 15:30:33.871 28280-28813/de.schmidt.android.passworttresor E/AndroidRuntime: FATAL EXCEPTION: ModernAsyncTask #1 10-07 15:30:33.871 28280-28813/de

Android error message on install “no content provider found”

可紊 提交于 2019-12-02 07:20:19
问题 I'm trying to write a broadcast receiver that gets called for every SMS text message that comes in. All the published code to do that (that I can find) either has been deprecated or doesn't work. My code fails at install time, with this message in the log (twice): 06-17 10:15:59.316 396 413 W ActivityManager: No content provider found for permission revoke: file:///data/local/tmp/locator.apk 06-17 10:15:59.316 396 413 W ActivityManager: No content provider found for permission revoke: file://