引起:android.content.res.Resources $ NotFoundException:字符串资源ID#0x7f060014
课程是:
public class Config {
private Properties configuration;
public static String root = Resources.getSystem().getString((R.string.app_name)) + "_data_file";
public File cartella = new File(Environment.getExternalStorageDirectory() + "/Android/obb/"+ root);
private String configurationFile = Environment.getExternalStorageDirectory() + "/Android/obb/"+ root + "/config.ini";
和String.xml是:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Il Maestro</string>
<string name="homefrontextb">Per iniziare,completa il modulo.</string>
<string name="homefrontext">Per iniziare,seleziona la tua lingua.</string>
<string name="action_settings">Settings</string>
<string name="sondaggiopub">Come hai conosciuto quest\' app?</string>
<string name="Pubblicita">Pubblicità</string>
<string name="socialnetwork">Social Network</string>
<string name="amici">Consigliata dagli amici</string>
<string name="store">Visita casuale sullo store</string>
<string name="namehome">Nome</string>
<string name="cognomehome">Cognome</string>
<string name="nickhome">Nickname</string>
<string name="emailhome">Email</string>
</resources>
然而,当我尝试将字符串作为int时,它可以工作,我得到的数字是“2131099668”
请帮帮我,我疯了..
答案 0 :(得分:1)
Resources.getSystem()
检索系统的资源,而不是您应用的特定资源。来自doc
返回仅提供访问权限的全局共享Resources对象 系统资源(没有应用程序资源),并且未配置 当前屏幕(不能使用尺寸单位,不改变基础 在方向等)。
您需要应用的上下文才能访问您的特定资源