首页 \ 问答 \ 如何从图像的缩略图路径获取imagepath?(How to get imagepath from thumbnail path of a image?)

如何从图像的缩略图路径获取imagepath?(How to get imagepath from thumbnail path of a image?)

我试图基于拇指路径获取imagepath,我已经尝试了从android-getting-path-to-image-from-thumbnail的解决方案,但它基于gridview位置,我只检索特定图像。 我还从SO中找到了一个示例代码,代码是

private String getImagePathFromThumbPath(String thumbPath)
    {
        String imgPath=null;

//      String[] projection = new String[] {MediaStore.Images.Thumbnails._ID, MediaStore.Images.Thumbnails.IMAGE_ID};
        String[] imagesDataPath={ MediaStore.Images.Media.DATA ,MediaStore.Images.Media._ID};
            //mResolver.query() requires android API 16
        Cursor thumbnails = mResolver.query(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, imagesDataPath,MediaStore.Images.Thumbnails.DATA+"=?",new String[]{thumbPath}, null, null);

        String[] filePathColumn = {MediaStore.Images.Media.DATA};

        Cursor imageCursor = mResolver.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, filePathColumn, MediaStore.Images.Media._ID + "=?", new String[] {thumbId}, null);

        if (imageCursor != null && imageCursor.moveToFirst()) {
            // Your file-path will be here
            imgPath= imageCursor.getString(imageCursor.getColumnIndex(filePathColumn[0]));
        }
        return imgPath;
    }

上面的方法是根据我的需要进行位修改,并且在Toasting上没有返回任何内容,请告诉我如何使用缩略图路径检索图像路径?


I am trying to get imagepath based on thumbail path , i have already tried solution from android-getting-path-to-image-from-thumbnail, but it is based on gridview position, i am only retrieving specific images. Also i found one sample code from SO, the code is

private String getImagePathFromThumbPath(String thumbPath)
    {
        String imgPath=null;

//      String[] projection = new String[] {MediaStore.Images.Thumbnails._ID, MediaStore.Images.Thumbnails.IMAGE_ID};
        String[] imagesDataPath={ MediaStore.Images.Media.DATA ,MediaStore.Images.Media._ID};
            //mResolver.query() requires android API 16
        Cursor thumbnails = mResolver.query(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, imagesDataPath,MediaStore.Images.Thumbnails.DATA+"=?",new String[]{thumbPath}, null, null);

        String[] filePathColumn = {MediaStore.Images.Media.DATA};

        Cursor imageCursor = mResolver.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, filePathColumn, MediaStore.Images.Media._ID + "=?", new String[] {thumbId}, null);

        if (imageCursor != null && imageCursor.moveToFirst()) {
            // Your file-path will be here
            imgPath= imageCursor.getString(imageCursor.getColumnIndex(filePathColumn[0]));
        }
        return imgPath;
    }

The above method is bit modified to suit my needs and it returns nothing on Toasting, please tell how to retrieve imagepath using thumbnail path?


原文:https://stackoverflow.com/questions/15548922
更新时间:2023-06-16 20:06

最满意答案

在这里,您可以找到问题的答案: WinConmss for WinForms不会在设计时加载


Here you can find an answer to your question: RadControls for WinForms are not loaded at design-time

相关问答

更多
  • 尝试将AutoGenerateColumns属性设置为false,并仅定义所需的列。 可能有些空字段来自您的数据源,因此您也应该调试它并查看ConvertCSVtoDataTable()方法返回的内容。 Try setting the AutoGenerateColumns property to false and define only the columns you need. Probably some empty fields come from your data source, so you ...
  • 不要使用ItemIndex 。 它只是网格的行索引。 相反,您希望在DataKeyNames中设置唯一ID。 理想情况下,您不希望实现自己的删除按钮,因为telerik已经有自动调用OnDeleteCommand的删除按钮。 这是RadGrid的首选方式。 ...
  • 总之,这里有一个关键问题: 只有在使用数据源控件绑定网格时才支持“自动”操作。 这包括 ObjectDataSource,因此您可以将DAL与ODS一起使用,然后支持自动插入/更新/删除。 直接绑定到数据表时,您必须手动处理更新。 这是因为它是数据源控件(而不是RadGrid)为CRUD操作提供了“自动”逻辑。 幸运的是,如果这是您喜欢的路径,手动处理更新并不困难。 查看Telerik.com上的一些演示示例: http://demos.telerik.com/aspnet-ajax/grid/exampl ...
  • 我对Telerik网格一无所知,但从您显示的错误看来,它们的行不是DataGridViewRow,而是GridViewRowInfo。 像这样重写你的代码,看它是否有帮助: foreach (Telerik.WinControls.UI.GridViewRowInfo row in RadGrid.Rows) { foreach (Telerik.WinControls.UI.GridViewCellInfo cell in row.Cells) { } } 请注 ...
  • 请尝试使用以下代码段。 private void DefineGridStructure() { DataTable current = (DataTable)Session["GridData"]; RadGrid grid = new RadGrid(); grid.ID = "RadGrid123"; grid.DataSource = current; if (!IsPostBack) { grid.AutoGenerateEdit ...
  • 我设法找到了解决这个问题的方法。 在ContactsSqlDataSource_Updating的第一部分,我现在有: string salutation = (editItem.FindControl("SalutationTextBox") as TextBox).Text; string firstName = (editItem.FindControl("FirstNameTextBox") as TextBox).Text; etc... string clientContactID = (edi ...
  • 在这里,您可以找到问题的答案: WinConmss for WinForms不会在设计时加载 Here you can find an answer to your question: RadControls for WinForms are not loaded at design-time
  • 你看过他们新的TreeList控件了吗? 它将分层视图与网格相结合。 我没有用它,但听起来像你可能需要的东西。 Have you looked at their new TreeList control? It combines a hierarchical view with a grid. I haven't used it, but it sounds like the kind of thing you may need.
  • 清楚地说,无论设想得当是什么,而且要轻声说出来的话。 如何:根据RadComboBox值显示/隐藏控件? 首先让我们声明一个包含3个内联项的简单RadComboBox:
  • 首先,每个列都指定一个不存在的ColumnGroupName。 您的两个组称为OtherDetails,ProductDetails称为Product和Other。 更改它们以解决异常。 其次,GridColumGroups只是组,因为它们不绑定到数据源中的任何数据; 它们只是为了美学。 Firstly, each one of your columns is specifying a ColumnGroupName that does not exist. Your two groups are call ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)