Ramesh Patwardhan
Ramesh Patwardhan

Reputation: 21

Deleting a file in JavaScript

I am developing a native android app using HTML/CSS/JavaScript. During the App flow, I need to permanently delete certain HTML files (stored locally). Can this be done?

I am a high school teacher trying to develop an educational app. I have basic knowledge of HTML/CSS and near zero knowledge of JavaScript!

Upvotes: 2

Views: 175

Answers (2)

Josh Lin
Josh Lin

Reputation: 2437

modern broswer support javascript file operation but this file system is only in broswer and isolated from local files, refer https://developer.mozilla.org/en/docs/Web/API/File

if u do need delete file on android system, then u need your app provide a bridge to and call from js, run in app, in java code, delete the file the code might look like

JsBradge.delete(file)

Upvotes: 1

Teo
Teo

Reputation: 240

Javascript disigned as a web document script language, so it has many security essentials, such as absolute isolation in browser, which means no write acces to file system. So, you have two options - first is create your own bridge to java, for example call prompt('your_file_name'), catch it in java and delete your_file_name. Second - use any of mobile app framework, for example - Cordova. Sorry, but no easy ways =(

Upvotes: 0

Related Questions