26.04.2011 19:53, Paul пишет:
Right, but in my case I am dealing with a physical file, not data
stored in a database.  I have physical .png files located in the
applications /files directory that I want to be able to send/share.

A ContentProvider doesn't have to be backed by a database.

Since yours is not, you can use MatrixCursor to build one row of data in memory in your query().

http://developer.android.com/reference/android/database/MatrixCursor.html

As I was originally copying the file over to the cache directory and
making them world readable via .exec(), I asked about spaces in
filenames.  I was told not to use this method, but to use the content
provider, but that only gets called if I move away from the file: uri
to the content: uri... but using a content provider, the share/send
seems to be expecting some kind of database implementation.

There is no expectation of a database.

Even though ContentProviders are often backed up by SQL databases, the abstraction is flexible enough to allow for non-database data (as is the case for your application).

Should I be looking for the file-specific uri in query() (those that
end with .png), and if that hits, then create and return a cursor that
contains the needed columns, fn, _data?

Remember that these URIs originate from your own code, and are opaque to all other applications.

There is really no need to be cryptic (e.g. content://paulsapp/item/2349), you can make them more convenient for yourself, for example:

content://paulsapp/cache/RealFileName.png

Writing query() should be really simple then.

Just for reference, Open Intents File Manager does something pretty close with its content URIs, so you are heading down a well trodden path.

-- Kostya

Thanks,

Paul

On Apr 26, 11:42 am, Kostya Vasilyev<[email protected]>  wrote:
>  Right.
>
>  Any sane application dealing with a content:// URI will want to know the
>  data item's title and size (at least).
>
>  It would do that by querying the URI for columns, defined here:
>
>  http://developer.android.com/reference/android/provider/MediaStore.Me...
>
>  using ContentResolver, which will direct the query back to your
>  ContentProvider's query method.
>
>  Looks like the MMS application also wants to get the actual filename
>  (the _data column).
>
>  -- Kostya
>
>  26.04.2011 19:29, Paul пишет:
>
>
>
>  >  That did it when it comes to my own call to:
>
>  >  getContentResolver().openFileDescriptor(validUri, "r");
>
>  >  It is now calling openAssetFile() in my content provider.  However, in
>  >  the usage of the send functionality with the content://... uri:
>
>  >  Intent share = new Intent(Intent.ACTION_SEND);
>  >  share.setType(StylePad.DEFAULT_MIME_PNG);
>  >  share.putExtra(Intent.EXTRA_STREAM, validUri);
>  >  startActivity(Intent.createChooser(share,
>  >  getString(R.string.activity_title_share)));
>
>  >  I am now getting a IllegalArgumentException thrown, and my openFile/
>  >  openAssetFile never gets called (the Exception is hitting before it
>  >  would get there I guess).  Here is the Exception:
>
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):
>  >  java.lang.IllegalArgumentException: column '_data' does not exist
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:
>  >  314)
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  android.database.CursorWrapper.getColumnIndexOrThrow(CursorWrapper.java:
>  >  99)
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  com.android.mms.ui.UriImage.initFromContentUri(UriImage.java:160)
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  com.android.mms.ui.UriImage.<init>(UriImage.java:90)
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  com.android.mms.ui.MMSMessage.addImage(MMSMessage.java:1076)
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  com.android.mms.ui.ConversationList.addMedia(ConversationList.java:
>  >  7095)
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  com.android.mms.ui.ConversationList.addAttachment(ConversationList.java:
>  >  8370)
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  com.android.mms.ui.ConversationList.handleIntent(ConversationList.java:
>  >  1860)
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  com.android.mms.ui.ConversationList.access$2800(ConversationList.java:
>  >  180)
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  com.android.mms.ui.ConversationList
>  >  $ThreadListQueryHandler.onQueryComplete(ConversationList.java:2999)
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  android.content.AsyncQueryHandler.handleMessage(AsyncQueryHandler.java:
>  >  344)
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  android.os.Handler.dispatchMessage(Handler.java:99)
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  android.os.Looper.loop(Looper.java:123)
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  android.app.ActivityThread.main(ActivityThread.java:4627)
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  java.lang.reflect.Method.invokeNative(Native Method)
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  java.lang.reflect.Method.invoke(Method.java:521)
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  com.android.internal.os.ZygoteInit
>  >  $MethodAndArgsCaller.run(ZygoteInit.java:871)
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
>  >  04-26 11:12:54.322: ERROR/AndroidRuntime(12440):     at
>  >  dalvik.system.NativeStart.main(Native Method)
>
>  >  Looking at the source:
>  >http://grepcode.com/file/repository.grepcode.com/java/ext/com.google....
>
>  >  So the Send functionality is querying my Provider's query() method,
>  >  which I can see, but it is looking for two columns that I simply don't
>  >  have, Part.FILENAME (column fn) and then if not found, column
>  >  Part._DATA (column _data).
>
>  >  Any ideas how to respond to this?


--
Kostya Vasilyev -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to