0

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

BeginnerProgrammer
  • 664
  • 3
  • 13
  • 27
  • possible duplicate of [how to read text file in javascript](http://stackoverflow.com/questions/13709482/how-to-read-text-file-in-javascript) – Voonic Sep 13 '13 at 05:40

1 Answers1

1

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'.

Selvam Palanimalai
  • 1,550
  • 1
  • 10
  • 13
  • 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 – BeginnerProgrammer Sep 13 '13 at 06:39
  • I dont think its possible to access local hard disk. JavaScript doesnt have access. – Selvam Palanimalai Sep 13 '13 at 13:59
  • You can run a local server on your computer and put those files in it. Access it from there. – Selvam Palanimalai Sep 13 '13 at 14:00
  • 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 :( – BeginnerProgrammer Sep 13 '13 at 14:39
  • You can store and retrieve data using localstorage. http://www.html5rocks.com/en/tutorials/file/filesystem/ . But you cannot access anything outside that :| – Selvam Palanimalai Sep 13 '13 at 14:43