android-contentprovider

android contacts provider: how to set phone number primary

眉间皱痕 提交于 2019-12-23 17:15:59
问题 How to set a contact's phone number to be primary number when adding or updating a contact building a custom contacts provider. The adding and updating of contacts is working fine but I don't know how to set one number of the contact to be primary, or default number. 回答1: mValues.put(Phone.IS_PRIMARY, 1); mValues.put(Phone.IS_SUPER_PRIMARY, 1); Both Phone.IS_PRIMARY and Phone.IS_SUPER_PRIMARY have to be set. 回答2: I had the same problem, my solution is: ContentProviderOperation.Builder bld =

Two content providers accessing the very same database

南笙酒味 提交于 2019-12-23 17:06:57
问题 Hi all! I wonder if there is a generally preferred implementation paradigm to respect if one want's two completely different Android applications to access and operate on the same database? Is it recommended or even technically possible to do this at all? What would such an architecture look like? As of now I'm considering to let the two applications implement their own ContentProvider s (both ContentProvider s will access the same database, guaranteed never simultaneously, though). I have

Should calls to a Content Resolver be done in a Service (i.e separate thread)?

心不动则不痛 提交于 2019-12-23 15:02:10
问题 I'm learning more about content providers in Android and they're performance. For example, if I write my own content provider (subclass ContentProvider) for SQLite operations and then I want to do an operation in an Activity's onPause() method, then in my Activity I would do: @Override protected void onPause (){ super.onPause(); // ...prepare myTransactionValues // This could be anything like insert, bulkInsert, query, delete, etc. getContentResolver().insert(CONTENT_URI, myTransactionValues)

android duplicate provider authority

纵然是瞬间 提交于 2019-12-23 08:11:12
问题 I have had users complaining of a "duplicate provider authority" error when trying to install my android application. I initially thought it might be an old version interfering with the new version, but they have never installed the app before. Any suggestions as to what might be causing this? 回答1: Somebody else used the same provider authority as you. AFAIK, that's the only way this error can occur. What did you choose as your provider authority? 来源: https://stackoverflow.com/questions

Deleting a single SQlite row RecyclerView onSwiped

本小妞迷上赌 提交于 2019-12-23 04:20:42
问题 I'm storing text items in a RecyclerView adapter and in a Content Provider. The list is accessible from the menu option. Items are deleted by swiping. Currently, the items are being saved, but not deleted. I've debugged and it shows that the "id" is 0(isn't being retrieved in the Main Activity): int id = (int) viewHolder.itemView.getTag(); The selected item isn't being swiped off the screen. I'm basing my code on this structure: https://www.javatips.net/api/ud851-Exercises-master/ud851

Retrieve data from content provider and display it on the other activity

纵然是瞬间 提交于 2019-12-23 03:33:31
问题 I'm working on Content Provider. I wrote a code for Inserting data and its working I want to retrieve data from the content provider and display it on the other activity I dont know how to proceed can any one help me out with the sample code? MainActivity.Java package com.example.cpdemo; import android.net.Uri; import android.os.Bundle; import android.app.Activity; import android.content.ContentUris; import android.content.ContentValues; import android.database.Cursor; import android.database

Accessing appSearchData bundle from ContentProvider

孤街醉人 提交于 2019-12-23 03:27:09
问题 An activity is supposed to be able to provide context information to a content provider like this: @Override public boolean onSearchRequested() { Bundle appSearchData = new Bundle(); appSearchData.putByte("category", category); startSearch(null, false, appSearchData, false); return true; } Search suggestions and results from the provider should be limited to 'category', but I can't find where to access the appSearchData bundle from my ContentProvider. 回答1: Use this for onSearchRequested:

Get all captured Videos in Android as a list

99封情书 提交于 2019-12-23 01:55:25
问题 I am trying to get all video available in gallery with below code, String[] proj = { MediaStore.Video.Media._ID,MediaStore.Video.Media.DATA,MediaStore.Video.Media.DISPLAY_NAME,MediaStore.Video.Media.SIZE }; videocursor = managedQuery(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,proj, null,null, null); int count = videocursor.getCount(); But I always get count = 0 , where was I made mistake ? I also tried Cursor videocursor = managedQuery(MediaStore.Video.Media.INTERNAL_CONTENT_URI, proj, null,

Get all captured Videos in Android as a list

落花浮王杯 提交于 2019-12-23 01:55:07
问题 I am trying to get all video available in gallery with below code, String[] proj = { MediaStore.Video.Media._ID,MediaStore.Video.Media.DATA,MediaStore.Video.Media.DISPLAY_NAME,MediaStore.Video.Media.SIZE }; videocursor = managedQuery(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,proj, null,null, null); int count = videocursor.getCount(); But I always get count = 0 , where was I made mistake ? I also tried Cursor videocursor = managedQuery(MediaStore.Video.Media.INTERNAL_CONTENT_URI, proj, null,

android bookmark ContentProvider makes bookmark but not visible in browser's bookmarks

跟風遠走 提交于 2019-12-22 12:39:19
问题 I'm using Android's Browser Bookmark ContentProvider to create a new bookmark programatically. The bookmark is created (I can retrieve it programatically via the ContentProvider) but the bookmark isn't visible in the browser bookmark view. Thoughts? // Saving the bookmark via ContentProvider final ContentValues bookmarkValues = new ContentValues(); bookmarkValues.put(Browser.BookmarkColumns.TITLE, title); bookmarkValues.put(Browser.BookmarkColumns.URL, url); final Uri newBookmark =