I have a simple .txt file with just a couple lines in right now, each line has a word then a comma then another word, representing a very simplistic username , password bank. Fo
final String PATH = "src\\main\\assets\\passwords.txt";
That's not going to work. Android is not Windows, and an Android device is not your Windows development PC.
First, \
is the Windows path separator. On OS X, Linux, and Android, the path separator is /
.
Second, src\main\assets\passwords.txt
is a file in your project. It is not a file on the filesystem of the Android device.
To access assets, use AssetManager
to open an InputStream()
. You can get an AssetManager
by calling getAssets()
on any handy Context
, such as your activity. Then, for your asset, call open("passwords.txt")
on the AssetManager
to get the InputStream
, that you can then use to read in the data.