I have a file in the resource folder. How can you get his way, in order to read?
Here is the function that reads the file.
public String readTextFile(Context ctx, int resId) { InputStream inputStream = ctx.getResources().openRawResource(resId); InputStreamReader inputreader = new InputStreamReader(inputStream); BufferedReader bufferedreader = new BufferedReader(inputreader); String line; StringBuilder stringBuilder = new StringBuilder(); try { while ((line = bufferedreader.readLine()) != null) { stringBuilder.append(line); stringBuilder.append('\n'); } } catch (IOException e) { return null; } return stringBuilder.toString(); } but how can I give him the path to the file (resId) if his name is not known?
I can get an array of all the elements that are there like this
Field[] raw = R.raw.class.getFields(); But how to get from it the path to the file to transfer it to the function that I described above for reading? Suppose I need the path to the first file in this array ...