0

I'm writing an app displaying html pages. By swiping or via a menu the different pages become visable.

the html pages are stored ar R.raw.file1 R.raw.file2

It is switching between the files with ' switch case '

 String myLoc[] = {"file1","file2"};

    //package name: com.ViewP.PageA
    int Loca = getResources().getIdentifier(myLoc[0], "raw" , "com.ViewP.PageA");
    int Locb = getResources().getIdentifier(myLoc[1], "raw" , "com.ViewP.PageA");

    switch(nmr){

    case 0:   inputStream = getResources().openRawResource(Loca); break;
    case 1:   inputStream = getResources().openRawResource(Locb); break;

default:  inputStream = getResources().openRawResource(R.raw.file1); 
}

This makes the app crash, however when I would use

    case 0:   inputStream = getResources().openRawResource(R.raw.file1); break;

it works perfectly.

Clearly storing the files in an array was done wrong (the method I found here on the forum). Please your comments and thoughts on this. I want to do it via an array because in the end many html files will be placed in the program and switch method is then not a 'smooth' way to do it. Making it more dynamic is in that case preferabele, i.e:

inputStream = getResources().openRawResource(loc[intLoc]);

With best regards,

Barbet

Bart

BarbetNL
  • 408
  • 2
  • 16

0 Answers0