简体   繁体   English

插入非媒体(pdf,txt,doc)android

[英]Insert Non media (pdf, txt ,doc) android

my application will downloads non media files like PDF,TXT, XML etc. Using following code I am saving in storage. 我的应用程序将下载非媒体文件,例如PDF,TXT,XML等。使用以下代码,我将其保存在存储中。

 FileOutputStream out = new FileOutputStream("Save locaation");

                    final int fileBufferSizee = 1024;
                    byte[] buffer = new byte[fileBufferSizee ];
                    int read;
                    while ((read = in.read(buffer)) != -1) {
                        out.write(buffer, 0, read);
                    }

                    in.close();
                    in = null;
                    out.flush();
                    out.close();
                    out = null;

working fine. 工作正常。 Actually I need URI of saved file. 实际上,我需要保存文件的URI。 for that I need to insert information in android media database. 为此,我需要在android媒体数据库中插入信息。

How to insert non media files in android media database ? 如何在Android媒体数据库中插入非媒体文件? any suggestions ? 有什么建议么 ?

if u want to get URL from absolute path then do this 如果您想从绝对路径获取URL,请执行此操作

 Uri.parse(new File("/sdcard/cats.jpg").toString()));

save this in one URI variable 将其保存在一个URI变量中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM