My question is that, if it is possible to get a variable from a .properties
or .txt
file. I need that in order to save the endPoint
, the server IP address. That way, every time that the IP address is changed, all you need to do is change the IP on the file, instead of compile the code again and build the apk, and install it again on the device. Any tips will be welcome.
UPDATE
I've been trying to use this plugin :File , but with no sucess. I want to use readAsText(path,file)
but all i get is undefined
import { File } from '@ionic-native/file/ngx';
constructor(
....
private file : File,
....
) { }
async test(){
this.promise = this.file.readAsText('file:///data/','ipAddress.txt');
await this.promise.then(value => {
console.log(value)
}).catch(error=> console.log("nao existe"))
}
And i'm getting the following error:
ERROR Error: Uncaught (in promise): FileError: {"code":1,"message":"NOT_FOUND_ERR"}
UPDATE Problem Solved. I was trying to acess to the internal storage, and the document was on the external storage. Make sure you use URI, path on android are different from computer. You need URI.
file:///storage/emulated/0/Android/data/
I called the method right on, when device's ready on app.component.ts
ngOnInit() {
.....
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
this.api.getURL();
.....
});
}
Hope i can help the next with the same problem I had.