android-contentprovider

Specifying limit / offset for ContentProvider queries

本小妞迷上赌 提交于 2019-11-27 00:38:12
问题 I'm trying to get my ContentResolver to run this query: select * from myTable limit 1 offset 2 The only query method in ContentResolver is: resolver.query(uri, projection, selection, selectionArgs, sortOrder); I've tried: final Cursor c = resolver.query( MyTable.CONTENT_URI, MyTable.PROJECTION, " ? ?", new String[] {"1", "2"}, null); Which just throws an IllegaLArgumentException. What is the correct way of achieving this? 回答1: I put the LIMIT clause in the sordOrder parameter, I've also seen

Android: Bulk Insert, when InsertHelper is deprecated

无人久伴 提交于 2019-11-27 00:23:32
问题 There is plenty answers and tutorials using InsertHelper to do fast bulk insert in SQLiteDatabase. But InsertHelper is deprecated as of API 17. What is now the fastest method to bulk insert large sets of data in Android SQLite ? So far my greatest concern is that SQLiteStatement is not very comfortable to work with, where InsertHelper had binding columns and binding values, which was kind of trivial. 回答1: SQLiteStatement has also binding methods, it extends SQLiteProgram. Just run it in

CursorLoader not updating after data change

给你一囗甜甜゛ 提交于 2019-11-27 00:17:42
I have created a small application, trying to understand the functionality of the LoaderManager and CursorLoader -classes. I have implemented LoaderCallbacks<Cursor> on my FragmentActivity -class and everything works fine, except the fact that when I update my data via ContentResolver.update() or ContentResolver.insert() -methods, onLoadFinished() is not called and as a result my data doesn't update. I have a custom ContentProvider and I am wondering if the problem is in my ContentProvider not notifying that the data changed or something else. Did you call setNotificationUri(ContentResolver cr

Insertion of thousands of contact entries using applyBatch is slow

五迷三道 提交于 2019-11-27 00:09:42
I'm developing an application where I need to insert lots of Contact entries. At the current time approx 600 contacts with a total of 6000 phone numbers. The biggest contact has 1800 phone numbers. Status as of today is that I have created a custom Account to hold the Contacts, so the user can select to see the contact in the Contacts view. But the insertion of the contacts is painfully slow. I insert the contacts using ContentResolver.applyBatch. I've tried with different sizes of the ContentProviderOperation list(100, 200, 400), but the total running time is approx. the same. To insert all

IllegalArgumentException: Unknown URL content:// CONTENT

筅森魡賤 提交于 2019-11-26 23:18:47
问题 IllegalArgumentException: Unknown URL content:// ^ Having a nightmare with the above. I've checked my variables and paths but can't see what the issue is? Greatly appreciate any pointers! Here's my trace. java.lang.IllegalArgumentException: Unknown URL content://com.purewowstudio.topmovies.data.FilmProvider/film_data at android.content.ContentResolver.insert(ContentResolver.java:1203) at com.purewowstudio.topmovies.data.DatabaseHelper.addFilm(DatabaseHelper.java:52) at com.purewowstudio

Group By in ContentResolver in Ice Cream Sandwich

房东的猫 提交于 2019-11-26 23:13:32
问题 I am making a query on the Android Contacts ContentProvider. I need a Group By clause. In Gingerbread and Honeycomb, I do something like this to search phone numbers and emails at the same time: (The actual WHERE clause is much more complicated as it includes types checks. This is a simplification, but it yields the same result) String request = Phone.NUMBER + " LIKE ? OR " + Email.DATA + " LIKE ?"; String[] params = new String["%test%", "%test%"]; Cursor cursor = getContentResolver().query(

How to observe contentprovider change? android

橙三吉。 提交于 2019-11-26 23:08:57
问题 I'v created a Contentprovide and implements it's update() method like this: @Override public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { final SQLiteDatabase db = mHelper.getWritableDatabase(); int count = db.update(InslideDB.FOLDER_TABLE, values, selection, selectionArgs); /* To notify the observer */ this.getContext().getContentResolver().notifyChange(URI, null); return count; } How can I get notified in my appwidget? Thanks! I'm trying this

Get specific contact information from URI returned from Intent.ACTION_PICK

谁说胖子不能爱 提交于 2019-11-26 22:55:25
问题 I am writing an Android app that has a data type that represents a person (specifically, the parent or guardian of a child). I'd like to be able to "import" the relevant data fields from the Contacts database in the Android device. (This should be optional; that is, it will not be a requirement that the parent/guardian is already in the Contacts database, nor will the Contacts database be updated if they add new parents/guardians.) So far, I have written code to start a new Intent to choose

Using build types in Gradle to run same app that uses ContentProvider on one device

筅森魡賤 提交于 2019-11-26 21:14:20
I have set up Gradle to add package name suffix to my debug app so I could have release version that I'm using and debug version on one phone. I was referencing this: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Types My build.gradle file looks like this: ... android { ... buildTypes { debug { packageNameSuffix ".debug" versionNameSuffix " debug" } } } Everything works fine until I start using a ContentProvider in my app. I get: Failure [INSTALL_FAILED_CONFLICTING_PROVIDER] I understand that this happens because two apps (release and debug) are registering same

How to add limit clause using content provider [duplicate]

巧了我就是萌 提交于 2019-11-26 20:56:08
问题 This question already has answers here : Specifying limit / offset for ContentProvider queries (4 answers) Closed last year . Is there a way to limit the number of rows returned from content provider? I found this solution, however, it did not work for me. All of the rows are still being returned. Uri uri = Playlists.createIdUri(playlistId); //generates URI uri = uri.buildUpon().appendQueryParameter("limit", "3").build(); Cursor cursor = activity.managedQuery(playlistUri, null, null, null,