android-contentprovider

Android when to use ContentResolver applyBatch or BulkInsert

ぐ巨炮叔叔 提交于 2019-12-10 12:34:43
问题 Right now for my application when I want to alter data for my ContentProvider, I just use the ContentResolver methods of insert, update, and delete. But on a couple of sample projects in the Android SDK, I notice they use applyBatch or BulkInsert. So I want to know when to use either of these methods and what are the advantages of using them over what I'm doing now. 回答1: Content Providers can have observers, such as Cursors, which are notified each time an insert, update or delete happens.

How would a thread created by an app be considered a different app from the app's ContentProvider?

家住魔仙堡 提交于 2019-12-10 12:32:23
问题 I have an app that, when notified by a ContentObserver of a change to a ContentProvider , attempts to query the provider on a background thread. This causes an SecurityException to be thrown: 8-10 15:54:29.577 3057-3200/com.xxxx.mobile.android.xxx W/Binder﹕ Caught a RuntimeException from the binder stub implementation. java.lang.SecurityException: Permission Denial: reading com.xxx.mobile.android.mdk.model.customer.ContentProvider uri content://com.xxx.mobile.android.consumer.xxx/vehicle from

SMS are duplicated as Calls(Samsung galaxy S II)

◇◆丶佛笑我妖孽 提交于 2019-12-10 11:49:31
问题 Ok, guys, here's my code for getting SMS: Cursor cursor = getContentResolver().query(Uri.parse(uri), null, CallLog.Calls.DATE + " > " + lastSmsTime, null, CallLog.Calls.DATE + " ASC"); Where type is: "content://sms/inbox" "content://sms/sent" And for calls: String[] projection = new String[] { CallLog.Calls.NUMBER, CallLog.Calls.TYPE, CallLog.Calls.DURATION, CallLog.Calls.DATE }; Cursor managedCursor = getContentResolver().query( CallLog.Calls.CONTENT_URI, projection, CallLog.Calls.DATE + " >

Android - SimpleAdapter filter query, how to ignore accents?

ε祈祈猫儿з 提交于 2019-12-10 10:55:44
问题 I am currently using the ContentProvider for contacts to retrieve the contacts from the device and allowing the user to filter the results by typing into an EditText. To do so I have set up a filter query on a SimpleAdapter as follows: contactsAdapter.setFilterQueryProvider(new FilterQueryProvider() { String[] PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.HAS_PHONE_NUMBER, }; String sortOrder = ContactsContract

Correct implementation of asynchronous Android SQLite database

送分小仙女□ 提交于 2019-12-10 10:24:26
问题 I've Googled around and have found multiple ways of accessing a local SQLite database asynchronously: AsyncTask CursorLoader (I've already used this for a query to retrieve my contacts information, but I'm not sure how this will translate to a SQLiteOpenHelper subclass with multiple queries) ContentProvider - Not sure if it's overkill, the database will only be need from within the app What is the best practice? I currently have a SQLiteOpenHelper subclass which contains the basic table

Android, content provider in library project

扶醉桌前 提交于 2019-12-10 02:39:48
问题 I have a library project providing the base code for a number of apps that all needs the same database structure and functionality and I'm looking for the best way to implement this. My main concern is really about how to provide a non static authority so I can override it with the package name of the app that uses the library. So in the library project I was thinking I could change the following constants to static methods that will accept a context that will allow me to get the authority

ContentProvider without SQL

元气小坏坏 提交于 2019-12-09 16:22:20
问题 I have two pieces of data that need to be accessed from outside applications and stored. According to documentation ContentProviders are the only possible way, but it also mentions external storage. ContentProviders implement a database-like "interface" and using a database would be extremely unnecessary for two pieces of data. I would rather save them to a file, but using a ContentProvider by implementing the abstract methods is problematic because the methods are structured as database

AccountManager does not add custom account in Android N preview

偶尔善良 提交于 2019-12-09 14:54:08
问题 I have implemented a sync adapter in my app which requires an account to be added in the device account settings. I followed the same approach given in the Android docs. It works fine till Marshmallow and I can see my account listed in the device accounts. But in Android N preview, account does not add to the device accounts. AccountManager's addAccountExplicitly() method always returns false. Has anyone faced this problem? 回答1: Not sure if this is the same issue, but there's an issue with

Difference between Shared Preferences and Content Providers in android

穿精又带淫゛_ 提交于 2019-12-09 12:21:42
问题 I know partially about Shared preferences and intents.But i want to know what are shared preferences and content providers in android ? And also what is the basic difference between intents , shared preferences and content providers . Please explain me this. 回答1: shared preferences are the location where you can store the secret information for your app, like setting cookies in the browser, this can be used for login credentials and other. where as content provider stores and retrieves the

How to open attachment list of media?

我怕爱的太早我们不能终老 提交于 2019-12-09 12:11:27
问题 In Android messaging, when click on attach it open the list of content provider like Camera, Gallery, Audio, Video etc . How to open the same list on button click? Like this : 回答1: What you want is actually a little complex: you need to call a method like this in your Activity private void showAddAttachmentDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(R.drawable.ic_dialog_attach); builder.setTitle(R.string.add_attachment);