android-contentprovider

Realm with Content Provider

我的梦境 提交于 2019-12-04 16:45:43
So, I've been used Realm for a while. For now, I have a task to share the login data with my other apps. Since the login data is stored using Realm. I choose to use Content Provider. I found an example: https://speakerdeck.com/androhi/realm-with-contentprovider Unfortunately, I was unable to make it work. This is my Content Provider in app A static final String[] sColumns = new String[]{ "LoginResultData" }; public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) { Realm mRealm = Realm

Obtaining contacts from content provider without duplicates or invalid contacts, and save to Realm

自古美人都是妖i 提交于 2019-12-04 16:28:00
I have this code (thankfully provided by @EpicPandaForce) and I have problem with deletion. When I add new contact it works like a charm while when I delete contact (or number from that contact if there are two of them) it stays persisted in Realm. How can I get it working properly? realm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { Contact realmContact = new Contact(); String filter = "" + ContactsContract.Contacts.HAS_PHONE_NUMBER + " > 0 and " + ContactsContract.CommonDataKinds.Phone.TYPE +"=" + ContactsContract.CommonDataKinds.Phone.TYPE_MAIN;

Trying to access the LauncherProvider

别来无恙 提交于 2019-12-04 14:50:12
问题 I am trying to access the LauncherProvider . You can find its source code here I tried to query this ContentProvider like this: Uri uri = new Uri.Builder().scheme("content").authority("com.android.launcher.settings").appendPath("favorites").build(); String[] projection = new String[]{ "_id", "title", "intent", "container", "screen", "cellX", "cellY", "spanX", "spanY", "itemType", "appWidgetId", "isShortcut", "iconType", "iconPackage", "iconResource", "icon", "uri", "displayMode" }; String

Update item in database without all of the columns set in ContentValues

青春壹個敷衍的年華 提交于 2019-12-04 13:22:25
问题 For example, I have four columns: first_name , last_name , phone_number and picture . Somewhere in my code there's: ContentValues values = new ContentValues(); values.put(MyPerson.FIRST_NAME, "Ted"); values.put(MyPerson.LAST_NAME, "Johnson"); values.put(MyPerson.PHONE_NUMBER, "111-111-1111"); values.put(MyPerson.PICTURE, "file://tedpicture.jpeg"); getContentResolver().update(tedUri, values, null, null); Could I run something like: ContentValues values = new ContentValues(); values.put

Use Android Contacts app to edit a raw contact which was added by a custom ContentProvider

点点圈 提交于 2019-12-04 12:44:21
My app adds contact ' Bob ' to the address book using a custom ContentProvider . In the Android Contacts app, Bob shows up just as any other (Google) contact. But when I edit Bob in the Contacts app, the data provided by my application is not editable. So far so good. My question is : From within my app, is there a way to fire up the Contacts app, in a way that allows the user to edit the portion of Bob that belongs to my app? I have tried to use the corresponding Intent , as described in this Android guide , but using the raw contact uri for Bob : Uri rawUri = getRawContactUri("Bob"); Intent

Android ContentResolver query sometimes not starting ContentProvider process

…衆ロ難τιáo~ 提交于 2019-12-04 09:05:43
I have been implementing my own custom content provider in an app A and want to query its database from a separate app B that calls ContentResolver.query(...) using the appropriate custom URI defined in A. All goes well when A has been running just before I launch B (thus A's process still running in the background). However when I kill A's process, then B fails to query A's database! I thought querying a content provider would automatically start its process so the data can be retrieved. Am I missing something? Some clarifications: I properly set up the content provider. There is no problem

What is the URI for SMS Draft Content Provider?

半世苍凉 提交于 2019-12-04 09:02:36
What is the Native Content URI for SMS Drafts? Content Provider URI for SMS is commonly content://sms/... and for SMS Drafts it is content://sms/drafts/ You can open each SMS message part by opening different ways. Inbox = "content://sms/inbox" Failed = "content://sms/failed" Queued = "content://sms/queued" Sent = "content://sms/sent" Draft = "content://sms/draft" Outbox = "content://sms/outbox" Undelivered = "content://sms/undelivered" All = "content://sms/all" Conversations = "content://sms/conversations" . 来源: https://stackoverflow.com/questions/10453385/what-is-the-uri-for-sms-draft

Order of installing the application is changing the behaviour?

谁都会走 提交于 2019-12-04 08:37:46
I have three applications: University, Student, Staff. University is the Main application. Student and Staff are provider application. University is having the permission to access the info from this provider applications. I installed the apk in following order student, staff and University . this is working fine But if i install in the order University, student and staff . In this case University is crashed and the error is "access permission is denied". Why this is happening even if we have proper permission? Why the provider installed later is not accessible by main application? 01-29 16:49

ContentObserver on content://sms/ in 1.6+?

别说谁变了你拦得住时间么 提交于 2019-12-04 08:09:13
I have a content observer that polls content://sms/ in android 1.5 so that I get notified of changes in the sms database and can react to them accordingly. However in 1.6 this doesn't work, has the uri been changed from content://sms/ to something else? I have seen content://mms-sms/ popping up in the logcat on my 1.6 device but I have tried that and it doesn't work. Here is my code String url = "content://sms/"; Uri uri = Uri.parse(url); getContentResolver().registerContentObserver(uri, true, new MyContentObserver(handler)); } class MyContentObserver extends ContentObserver { public

ContentProvider won't show up in Data & Synchronization area

早过忘川 提交于 2019-12-04 07:28:44
I'm trying to get a custom ContentProvider to show up under Data & synchronization, and I'm running into some problems. Namely, it's not showing up. The specifics: My AndroidManifest.xml has the provider and service: <provider android:name="BooksProvider" android:label="ClientName Books" android:authorities="com.clientname.reader.books" android:enabled="true" android:exported="true" android:syncable="true"> <grant-uri-permission android:pathPattern=".*" /> </provider> <service android:name=".sync.SyncService" android:exported="true" android:process=":sync"> <intent-filter> <action android:name