1

i have a problem. I'm creating an application that stores data in the cell , but first create a folder that will contain the various files . This folder will have the name of the app, but continuoa receive an error at that point.

Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f060014

The class is:

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";

and String.xml is:

    <?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>

However , when I try to get the string as int , it works , and I get the number " 2131099668 "

Please help me , I'm going crazy ..

1
  • Try Change from Resources.getSystem() to getResources(). Commented Jul 31, 2015 at 18:27

1 Answer 1

1

Resources.getSystem() retrieves the System's resources, not the one specific of your app. From the doc

Return a global shared Resources object that provides access to only system resources (no application resources), and is not configured for the current screen (can not use dimension units, does not change based on orientation, etc).

You need your app's context to access your specific resources

Sign up to request clarification or add additional context in comments.

2 Comments

Write a code example, I can not understand what you mean.
I have resolved... Thanks you so much!!! it have declared a function with context and called method in a main!!! Thank you,you saved my life hahaha

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.