android-contentprovider

Android: Bulk Insert, when InsertHelper is deprecated

旧城冷巷雨未停 提交于 2019-11-28 04:24:48
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. SQLiteStatement has also binding methods, it extends SQLiteProgram . Just run it in transaction: final SQLiteDatabase db = mOpenHelper.getWritableDatabase(); final SQLiteStatement statement = db

using ContentProviderClient vs ContentResolver to access content provider

元气小坏坏 提交于 2019-11-28 03:05:47
The documentation on Android content providers describes using a ContentResolver , obtained from getContentResolver() , to access the content. However there is also a ContentProviderClient , which can be obtained from getContentResolver().acquireContentProviderClient(authority) . It seems to provide more or less the same methods available in the ContentResolver for accessing content from the provider. When should I use a ContentProviderClient instead of just using the ContentResolver directly? What are the benefits? jcwenger Your android device has many databases, each of which is identified

How does CursorLoader with LoaderManager know to send the cursor to a CursorAdapter?

╄→尐↘猪︶ㄣ 提交于 2019-11-28 02:51:09
I was going through some of my code and I realized I don't actually know how a CursorLoader and LoaderManager combination used with a CursorAdapter connect. Heres the part that I am confused in. agendaAdapter = new MyAgendaAdapter(this, null); makeProviderBundle(new String[] {"_id", "event_name", "start_date", "start_time", "end_date", "end_time", "location"}, "date(?) >= start_date and date(?) <= end_date", new String[]{getChosenDate(), getChosenDate()}, null); getLoaderManager().initLoader(0, myBundle, MainDisplayActivity.this); list.setAdapter(agendaAdapter); So how does the query() method

Why/Should we implement BaseColumns when using a Content Provider in Android?

谁说胖子不能爱 提交于 2019-11-28 02:41:52
问题 I was browsing the source code for Google IOSched App and noticed the following code snippet as part of their Content Provider implementation: public static class Blocks implements BlocksColumns, BaseColumns . As far as I know BaseColumns is simply an interface to two constants: _COUNT and _ID . I have two questions: What are the advantages/disadvantages of the implementing BaseColumns as opposed to having a private field _ID in the class directly? What is the role of the constant _COUNT ?

How to put a video file in android custom content provider

一笑奈何 提交于 2019-11-28 01:40:51
I have a video file. i want to store it in a custom content provider. and after that i want to read it and want to play it through Uri. Below is my code. package com.videocon.nds; public class FileProvider extends ContentProvider { public static final Uri CONTENT_URI=Uri.parse("content://com.videocon.nds/"); private static final HashMap<String, String> MIME_TYPES=new HashMap<String, String>(); static { MIME_TYPES.put(".mp4", "video/mp4"); } @Override public boolean onCreate() { File f=new File(getContext().getFilesDir(), "Holy.mp4"); if (!f.exists()) { AssetManager assets=getContext()

IllegalArgumentException: Unknown URL content:// CONTENT

那年仲夏 提交于 2019-11-27 23:16:15
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.topmovies.fragments.FilmList$getFilms.onPostExecute(FilmList.java:72) at com.purewowstudio.topmovies

How to add limit clause using content provider [duplicate]

走远了吗. 提交于 2019-11-27 22:12:51
This question already has an answer here: Specifying limit / offset for ContentProvider queries 4 answers 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, null); I have had this issue and had to break my head till I finally figured it out, or rather got a whay that worked for me

How to observe contentprovider change? android

天涯浪子 提交于 2019-11-27 22:12:26
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 Resolver but no Log (--------------------Date Changed) print: class DataProviderObserver extends

Where is the SampleZipfileProvider class?

本秂侑毒 提交于 2019-11-27 21:27:43
At the bottom of the section in Google's dev guide on expansion files ( http://developer.android.com/guide/market/expansion-files.html#ZipLib ) there is the following text. APEZProvider - Most applications don't need to use this class. This class defines a ContentProvider that marshals the data from the ZIP files through a content provider Uri in order to provide file access for certain Android APIs that expect Uri access to media files. The sample application available in the Apk Expansion package demonstrates a scenario in which this class is useful to specify a video with VideoView

Get specific contact information from URI returned from Intent.ACTION_PICK

一世执手 提交于 2019-11-27 20:12:17
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 the specific Contact (using Intent.ACTION_PICK). I then get a URI that represents a specific Contact in