“未解析的引用”无法访问 Android 中的属性文件

尼克松

我正在关注这个线程:Android Config File,创建一个 config.properties 文件,我可以从中读取。现在我有一个原始文件夹,其中有一个我试图访问的 config.properties 文件:
res
--> raw
----> config.properties

import android.R
import android.content.Context
import android.content.res.Resources
import java.io.InputStream
import java.util.*

class ConfigurationManager(context: Context){
    init {
        val resources: Resources = context.resources
        val rawResource: InputStream = resources.openRawResource(R.raw.config) //this doesn't work
    
        val properties = Properties()
        properties.load(rawResource)
    }
}

但我收到“未解析的参考:配置”错误

未解决的参考:配置

为什么这不能编译以及如何解决这个问题?

共享软件

消除:

import android.R

那就是导入框架的 R类。您希望使用自己的资源为您自己的应用程序生成代码。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章