filesystem vs storage or something else, one time welcome screen

Hi! Im basically trying to make a one time welcome help screen. I was thinking at the end of the “tutorial” I would make a persistent change in the app that allows users too go directly to the app the next time.

So writing something to a file might be the right answer but Im open for other solutions.

However if writing something to a file so the app knows to skip the tutorial is the right answer, the two different modules seem to do the same thing (though filesystem adds more functionality I guess), is there any benefit of choosing one over the other in my case?

Hi Paul,

writing something [useful] to a local file is, indeed, the suggested solution for that challenge.

As for choosing the right module, prefer FileSystem over Storage, because FileSystem API will be receiving more care in the future and simply is better.

thanks! as a curiosity, are these types of files written as .txt usally? or is there a better way, its literally going to be a true or false file.

Maybe a check if an empty file with a certain name exists or not is better?

config file?

Im full of ideas

I would personally store JSON data structures in such files, mostly because it’s easy to read/write and work with them. And then it makes sense that you call it appname.json, for example.

This is just a personal preference though, so go wild :slight_smile:

continuation post (happy to repost as a new thread if needed)

let Observable = require("FuseJS/Observable");
let FileSystem = require("FuseJS/FileSystem");

let path = FileSystem.dataDirectory + "/" + "lett.json";

FileSystem.exists(FileSystem.dataDirectory + "/lett.json")
.then(function(x) {
    if(x){
        FileSystem.readTextFromFile(path)
        .then(function(y) {
            console.log("log " + y);
            if(JSON.parse(y).welcomed.toString() === "yes"){
                router.push("LoginPage");
            }
        });
    }
});

function pushApp(){
    let settings = { "welcomed": "yes" };
    FileSystem.writeTextToFile(path, JSON.stringify(settings))
    .then(function(){

            console.log("log ");
        router.push("LoginPage");
    });
}

module.exports = {
    pushApp: pushApp,
};

This is my js code, but I dont think the file stays on my mobile device or something?

I restart the app and the welcome screen pops up again.

I built on samsung s7 from windows 10 with fuse build --target=Android --run

btw it works on local preiew and then i uno clean to remove the file

Hi Paul,

it looks like this one will need a little debugging, so hang tight and someone will get back to you.

Hello. :slight_smile:

By restarting the app, do you mean running fuse build --target=Android --run again, or closing and starting the app again on the mobile device?

It is expected that the FileSystem.dataDirectory is wiped between builds, but not when simply restarting the app on the mobile device. If the latter is the case, then there’s definitively something wrong going on.

nvm it works now

…I expect it was wizards