I figured out a way to do it finally. This is the code that works in my case. I have a class which maintains the names of the file in accordance to the count number. File name is sent dynamically depending on the count to the method below. the method below dynamically reads that file and returns the string and sets it to the TextView
on swipe. swiping left and right, increments and decrements the count respectively. Similar code is maintained for animation and sound files. This works smoothly.
public String readTxt(String fileName)
{
try {
InputStream is;
is = context.getAssets().open(fileName + ".txt");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int i;
i = is.read();
while (i != -1)
{
byteArrayOutputStream.write(i);
i = is.read();
}
is.close();
return byteArrayOutputStream.toString();
}
catch (IOException e)
{
e.printStackTrace();
}
return fileName;
}
Better and more efficient solutions are welcome. For now am accepting this answer. Thanks all for the replies.