The Java RandomAccessFile class is used to access files in random way, this means it allows you to move around a file and read from it or write to it as you want. Thing that is not possible with the traditional FileInputStream
or FileOutputStream
classes.
If your code uses this class, the exception on the IDE "Cannot resolve symbol 'RandomAccessFile'" will appear due to the absence of importing the related class. This class can be imported in your class with the following line at the top of your class:
import java.io.RandomAccessFile;
Don't forget as well that Android Studio has an autoimport feature that recognizes classes if they're already in the android namespace. This dialog appears if you wait enough over the same line of code that throws the exception (the time differs of your device performance):
Pressing Alt + Enter on the recommendation will auto import the java.io.RandomAccessFile
namespace at the beginning of your Java code.
Happy coding !