i want to Build Android Apps with HTML, CSS, and JavaScript. I need to read file. A local file that contain questions (A data base of question). i think it is possible with javaScript , is it true? please help and share your information. Thanks in advance
1 Answer
Yes, using HTML5 FileReader API. The best source for that is , http://www.html5rocks.com/en/tutorials/file/dndfiles/.
Scroll down to reading files.
FileReader.readAsText(Blob|File, opt_encoding)
Split the content with EOL character for UTF-8.
Note: By default the string is decoded as 'UTF-8'.
5 Comments
BeginnerProgrammer
thanks , can i get a static path file to this function , i have a data base store in a file and I want to read this data base so it's path is specified. can i load this file automatically? thanks for your answer
Selvam Palanimalai
I dont think its possible to access local hard disk. JavaScript doesnt have access.
Selvam Palanimalai
You can run a local server on your computer and put those files in it. Access it from there.
BeginnerProgrammer
every thing is static, i mean i don't want to connect to server.i am just using html,jS & css that can be run on mobile like games that every body install on mobile without need to use internet. sorry for my pure English , i hope understand my mean :(
Selvam Palanimalai
You can store and retrieve data using localstorage. html5rocks.com/en/tutorials/file/filesystem . But you cannot access anything outside that :|