0
How do I read data from a file properties
on Android?
Follows my code from onCreate
:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
File file = new File(getPackageName()+ "/dados.properties");
Properties pp = new Properties();
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
pp.load(fis);
fis.close();
} catch (Exception e) { }
}
There’s always a mistake in fis = new FileInputStream(file);
.
Enter which error is occurring. It is probably due to the path to the file not being found. Search on how to get the application directory (where you probably want to save the properties file), for example here.
– Piovezan