I developed my app for Windows and it works perfectly fine. So after some time I tried to build it to Android, it come with an error
E/Box (30248): Storage error "Read-only file system" (code 30)
I have read the doc from Objectbox and I know that it is because I tried to access a read only directory. Pretty self explanatory. My question is then how do I fix it ? How do I access the not read-only ?
Here is my code to initialize my Store
Directory paths = Directory("");
getApplicationDocumentsDirectory().then((dir) => paths = dir);
_store = Store(getObjectBoxModel(),directory: p.join(paths.path, 'objectBoxMyDirectory'));
Thanks y'all
getApplicationDocumentsDirectory
returns a Future
, meaning there is an delay, .then()
is not called immediately.
You can use
final dir = await getApplicationDocumentsDirectory();
_store = Store(getObjectBoxModel(), directory: p.join(paths.path, 'objectBoxMyDirectory'));
or if you cannot make your function async
() async {
final dir = await getApplicationDocumentsDirectory();
_store = Store(getObjectBoxModel(), directory: p.join(paths.path, 'objectBoxMyDirectory'));
}();