How to resolve Android Studio Error: Cannot resolve symbol 'RandomAccessFile'

How to resolve Android Studio Error: Cannot resolve symbol 'RandomAccessFile'

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:


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):

Android Studio Class Autocomplete (auto import)

Pressing Alt + Enter on the recommendation will auto import the namespace at the beginning of your Java code.

Happy coding !

This could interest you

Become a more social person