Giter Club home page Giter Club logo

Comments (17)

Chhekur avatar Chhekur commented on August 25, 2024

You can not write files that are inside the assets folder because at the run time these files are no more in assets.

You can read/write files in users directory
Check here

from androidjs.

 avatar commented on August 25, 2024

You can not write files that are inside the assets folder because at the run time these files are no more in assets.

You can read/write files in users directory
Check here

thanks for the answer
but how can I defiene "app" ? I used this but wont help:

const app = require ( 'androidjs' ).app;

from androidjs.

Chhekur avatar Chhekur commented on August 25, 2024

You can not write files that are inside the assets folder because at the run time these files are no more in assets.
You can read/write files in users directory
Check here

thanks for the answer
but how can I defiene "app" ? I used this but wont help:

const app = require ( 'androidjs' ).app;

app module is given in front process

from androidjs.

 avatar commented on August 25, 2024

app module is given in front process

but I need to deal with it in back process, is there any chance to get the 'userData' Folder's Path, in order to write on it, in Back process?

from androidjs.

Chhekur avatar Chhekur commented on August 25, 2024

app module is given in front process

but I need to deal with it in back process, is there any chance to get the 'userData' Folder's Path, in order to write on it, in Back process?

You can use IPC to share information between front and back process.

from androidjs.

 avatar commented on August 25, 2024

You can use IPC to share information between front and back process.

I used that but in Mobile it immediately closes:

// ------- send App Location to back
let path = app.getPath('userData');
front.send ( 'here' , path );

back.on ( 'here' , function (data) { const here = data; } );
answer = Object.assign ( {} , answer_template );
answer[ 'stat' ] = 'looking_in';

directories = fs.readdirSync ( here );
answer[ 'retrieved_data' ] = directories;
back.send ( 'Hey_you' , answer );

from androidjs.

Chhekur avatar Chhekur commented on August 25, 2024

You can use IPC to share information between front and back process.

I used that but in Mobile it immediately closes:

// ------- send App Location to back
let path = app.getPath('userData');
front.send ( 'here' , path );

back.on ( 'here' , function (data) { const here = data; } );
answer = Object.assign ( {} , answer_template );
answer[ 'stat' ] = 'looking_in';
directories = fs.readdirSync ( here );
answer[ 'retrieved_data' ] = directories;
back.send ( 'Hey_you' , answer );

You have to read read operations inside the callback function because javascript is async or you can use promise

from androidjs.

Chhekur avatar Chhekur commented on August 25, 2024

You can use IPC to share information between front and back process.

I used that but in Mobile it immediately closes:

// ------- send App Location to back
let path = app.getPath('userData');
front.send ( 'here' , path );

back.on ( 'here' , function (data) { const here = data; } );
answer = Object.assign ( {} , answer_template );
answer[ 'stat' ] = 'looking_in';
directories = fs.readdirSync ( here );
answer[ 'retrieved_data' ] = directories;
back.send ( 'Hey_you' , answer );

You have to read read operations inside the callback function because javascript is async or you can use promise

Did you write this whole thing inside the ipc callback

from androidjs.

 avatar commented on August 25, 2024

Did you write this whole thing inside the ipc callback

this part in front:

// ------- send App Location to back
let path = app.getPath('userData');
front.send ( 'here' , path );

this part in back:

back.on ( 'here' , function (data) { const here = data; } );
answer = Object.assign ( {} , answer_template );
answer[ 'stat' ] = 'looking_in';

fs.readdir ( here , (err, directories ) => {

answer[ 'retrieved_data' ] = directories;
back.send ( 'Hey_you' , answer );

} );

I changed readdirSyc to readdir, but still it closes

from androidjs.

Chhekur avatar Chhekur commented on August 25, 2024

Did you write this whole thing inside the ipc callback

this part in front:

// ------- send App Location to back
let path = app.getPath('userData');
front.send ( 'here' , path );

this part in back:

back.on ( 'here' , function (data) { const here = data; } );
answer = Object.assign ( {} , answer_template );
answer[ 'stat' ] = 'looking_in';
fs.readdir ( here , (err, directories ) => {

answer[ 'retrieved_data' ] = directories;
back.send ( 'Hey_you' , answer );

} );

I changed readdirSyc to readdir, but still it closes

You have to write whole dependent code inside the back's callback.

Do you know how javascript works ?

from androidjs.

 avatar commented on August 25, 2024

Did you write this whole thing inside the ipc callback

this part in front:

// ------- send App Location to back
let path = app.getPath('userData');
front.send ( 'here' , path );

this part in back:

back.on ( 'here' , function (data) { const here = data; } );
answer = Object.assign ( {} , answer_template );
answer[ 'stat' ] = 'looking_in';
fs.readdir ( here , (err, directories ) => {

answer[ 'retrieved_data' ] = directories;
back.send ( 'Hey_you' , answer );

} );

I changed readdirSyc to readdir, but still it closes

You have to write whole dependent code inside the back's callback.

Do you know how javascript works ?

it has been summarized here, it is a part of over 1500 lines of coeds,
this part will be triggered in appropriate time: (it is a tiny part of a function named looker, which will call in later, and if I set the here to /sdcard/www/content it works fine )

answer = Object.assign ( {} , answer_template );
answer[ 'stat' ] = 'looking_in';
fs.readdir ( here , (err, directories ) => {

answer[ 'retrieved_data' ] = directories;
back.send ( 'Hey_you' , answer );

from androidjs.

Chhekur avatar Chhekur commented on August 25, 2024

Did you write this whole thing inside the ipc callback

this part in front:

// ------- send App Location to back
let path = app.getPath('userData');
front.send ( 'here' , path );

this part in back:

back.on ( 'here' , function (data) { const here = data; } );
answer = Object.assign ( {} , answer_template );
answer[ 'stat' ] = 'looking_in';
fs.readdir ( here , (err, directories ) => {

answer[ 'retrieved_data' ] = directories;
back.send ( 'Hey_you' , answer );

} );

I changed readdirSyc to readdir, but still it closes

You have to write whole dependent code inside the back's callback.
Do you know how javascript works ?

it has been summarized here, it is a part of over 1500 lines of coeds,
this part will be triggered in appropriate time: (it is a tiny part of a function named looker, which will call in later, and if I set the here to /sdcard/www/content it works fine )

answer = Object.assign ( {} , answer_template );
answer[ 'stat' ] = 'looking_in';
fs.readdir ( here , (err, directories ) => {

answer[ 'retrieved_data' ] = directories;
back.send ( 'Hey_you' , answer );

Yeah, I am not saying to write whole thung inside the callback but you have to write whole code which are dependent on here inside the callback

from androidjs.

 avatar commented on August 25, 2024

Yeah, I am not saying to write whole thung inside the callback but you have to write whole code which are dependent on here inside the callback

so do you mean this code :

back.on ( 'here' , function (data) { const here = data; } );

will not set here globally?!

from androidjs.

Chhekur avatar Chhekur commented on August 25, 2024

Yeah, I am not saying to write whole thung inside the callback but you have to write whole code which are dependent on here inside the callback

so do you mean this code :

back.on ( 'here' , function (data) { const here = data; } );

will not set here globally?!

No, not at all because of async behaviour of javascript.

from androidjs.

 avatar commented on August 25, 2024

Yeah, I am not saying to write whole thung inside the callback but you have to write whole code which are dependent on here inside the callback

so do you mean this code :

back.on ( 'here' , function (data) { const here = data; } );

will not set here globally?!

No, not at all because of async behaviour of javascript.

so How can I send here to back at the starting of the App and keep here for entire Time and use it as other const vars?

from androidjs.

Chhekur avatar Chhekur commented on August 25, 2024

Not possible to save the value of here because of js async behaviour.
I used the same concept in sample story app, you can check soruce for the reference.

from androidjs.

EmilDeGuerrero avatar EmilDeGuerrero commented on August 25, 2024

Hi its been a while nobady make a comment.

Please im trayng to read files im the back. but it does not work outside of appData folder.
can anybody please giveme me some info.
i added

...
"permission": ["android.permission.INTERNET", "android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE"],
...

in the package.json
without siccess.

note that if i run the app im the pc and in a virtual android machine i have it works, but in a fone it does not work outsidr of appData.

hope anybody read this and help.

from androidjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.