简体   繁体   English

如何在Android中将文件写入原始文件夹?

[英]How to write a file in Android to the raw folder?

I think this is a pretty basic question. 我认为这是一个非常基本的问题。

I am currently writing a file like this: 我目前正在写一个这样的文件:

File output = new File("exampleout.mid");

Now, I want to write the file to ../myproject/res/raw 现在,我想将文件写入../myproject/res/raw

I read I could do it by putting the complete url in the "". 我读过我可以把完整的URL放在“”中。 BUT. 但。 Since this is an Android app. 由于这是一款Android应用。 What is the full url? 什么是完整网址? I don;t have to write /home/.../myproject/...? 我不必写/ home /.../ myproject / ...?

Is the solution: 是解决方案:

File output = new File("/res/raw/exampleout.mid");

Or do I need a higher url structure? 或者我需要更高的网址结构?

Sorry about asking this simple question, but since I use an Android emulator, I cannot check if the file is actually in the right place. 很抱歉问这个简单的问题,但由于我使用Android模拟器,我无法检查文件是否确实在正确的位置。

You cannot write a file to raw folder. 您无法将文件写入原始文件夹。 Its read-only. 它是只读的。 Precisely you can't modify anything contained within "Res" folder on the fly. 准确地说,您无法动态修改“Res”文件夹中包含的任何内容。

Check this out, https://stackoverflow.com/a/3374149 看看这个, https://stackoverflow.com/a/3374149

If you want to use iText on Android or the Google App Engine, you need to use iTextG. 如果您想在Android或Google App Engine上使用iText,则需要使用iTextG。

dependencies {
    compile 'com.itextpdf:itextg:5.5.10'
}

Source: iText Official Site 资料来源: iText官方网站

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

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