I want to create file in which the first line will be constantly updated. actually I want to save this file to custom path, for example /storage/emulated/0/Download, but I don't know how to do that, so now I have something like this:
public void save(){
while(true) {
try {
String FILENAME = "my_file";
String string = "" + System.currentTimeMillis();
FileOutputStream fos = openFileOutput(FILENAME, MODE_PRIVATE);
fos.write(string.getBytes());
} catch (Exception e) {
e.printStackTrace();
}
}
}
and this code gives me two errors
FileOutputStream fos = getApplicationContext().getContextResolver().openFileOutput(FILENAME);
Before using openFileOutpout()
you have to use getContextResolver()
and there is no Context.MODE_PRIVATE
parameter in this function
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.