Question: I want to make a new layout file at run time (via source code) and save it into res/layout. I tried may ways for this but not successful.

One of the way I tried:

```
    getApplicationContext().getResources().getString(R.layout.activity_main);

    File src = new File(src);

    FileInputStream stream = null;

    try {
        stream = new FileInputStream(src);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

```

But I am getting FileNotFoundException.

Please help me .

Answer: 
In Android resource files are pre compiled in APK and in class R the id references are stores for performance reasons. It doesn't make any sense you trying to do so, it is not possible. What is the purpose of this?

When you like to have dynamic layouts create them by code.
That's not possible.You can't modify resources once apk file is generated.