thank you for this great help but unfortunately this isn't my case. not me who created the cursor and iterate through it. I am just receiving the Uri from another activity via an intent. and it isn't good to iterate through all images to find one its Uri matches one I received especially that I am not sure it will always be a Uri of an image.
still can I get the file name? On Jul 22, 4:04 pm, Kacper86 <[email protected]> wrote: > Hi, > > The problem is that it should be documented in the Android Reference, > here: > > http://developer.android.com/reference/android/provider/MediaStore.Im...http://developer.android.com/reference/android/provider/MediaStore.Im... > > But, as far as i understand, it's not complete. Fortunately, we can > check it in a different way. > > <android code> > Uri u = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; > //sdcard only > Cursor c = managedQuery(u, null, null, null, null); > > if (c.moveToFirst()) { > do { > int max = c.getColumnCount(); > for (int i = 0; i < max; i++) { > String colName = c.getColumnName(i); > String value = c > > .getString(c.getColumnIndex(colName)); > > if (colName != null){ > Log.d("columnName: ", > colName); > } > > if (value != null) { > Log.d("value", value); > } > } > } while (c.moveToNext()); > } > </android code> > > Check LogCat and you'll notice that we have all column names with > their values. I suppose, you'd be interested in: > > 07-22 12:50:09.973: DEBUG/columnName:(3049): _data > 07-22 12:50:09.973: DEBUG/value(3049): /sdcard/download/vienna-s- > schonbrunn-zoo-and-giant-ferris-wheel-in-vienna-1.jpg > (...) > 07-22 12:50:09.983: DEBUG/columnName:(3049): _display_name > 07-22 12:50:09.983: DEBUG/value(3049): vienna-s-schonbrunn-zoo-and- > giant-ferris-wheel-in-vienna-1.jpg > > If you have got any questions, don't hesitate to ask. > > Greetings! > > On Jul 22, 10:28 am, Mina Shokry <[email protected]> wrote: > > > Hello, > > > I am using content provider to access images in phone gallery and > > everything works fine except one thing that I want to get the physical > > file name of images I access. Can I get a java.io.File object from > > android.net.Uri object? > > if no, is there any other way to accomplish such a task? > > I just need to know the file name! > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" 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-beginners?hl=en -~----------~----~----~----~------~----~------~--~---

