How to read directory from sdcard in phonegap

1
19848

In this session we will learn how to read directory from sdcard in phonegap i.e we will read the directories present in the sdcard and display it in the list format .

    Read directory from sdcard in phonegap

  • Follow the steps given below :

  1. First of all download gitbash and Xampp server in your machine .
  2. Now go to your Xampp -> htdocs folder .
  3. In this htdocs folder create a new folder say ReadDirectory .
  4. In this ReadDirectory create a new file called as index.html and write the following code in it :
  5. Here are the screen shots for the code :
  6. read directory from sdcard
    phonegap read directory app
    read directory from sdcard

  7. Now we have to download the javascript that we have used in the program,so go to jquerymobile.com you will be navigated to the following window :
  8. read directory from phonegap

  9. Select the required minified version of javascript and you will get the code as shown below :
  10. Phonegap read directory app

  11. Now press ctrl + u and you will get the view-source code of it .
  12. Read directory from sdcard in phonegap

  13. Now select all the view-source code copy and paste it in a text file say jquery.mobile-1.3.2.min.js .
  14. 10. Now in your ReadDirectory folder create new folder called as js and save this jquery.mobile-1.3.2.min.js file in it.
  15. Similarly create another file say jquery-1.10.2.min.js and download the code for it and paste this file in js folder .
  16. Thus now in js folder you will be having your two files as shown below :
  17. read directory from sdcard in phonegap

  18. Similarly create a css folder in your ReadDirectory folder and download the css code for the required version and copy and paste the code in the file and save it with css extension as shown below :
  19. Phonegap app

  20. Thus in your ReadDirectory folder you will have following contents :
  21. sdcard application using phonegap

  22. Now to push your application on github follow the given steps .
  23. Hence after writing the code save your document and now sign in into your Github account by visiting github.com :
  24. 0

  25. So now enter a username ,your email id and password in the respective tabs and click on the Sign up for GitHub button .
  26. After you click on the signup button you will get the following window :
  27. 0.1

  28. Now click on the ‘+’ icon on the right hand side as indicated by the red arrow and then click on the “ New repository ” as indicated by the blue arrow .
  29. 0.2

  30. After clicking on the New repository you will be navigated to the next window ,specify a Repository name ,select a public radio button and click on the Create repository button as shown in the image below :
  31. 0.3

  32. So after clicking on the Create repository button you have the following window :
  33. 0.4

  34. Go to xampp -> htdocs .
  35. In htdocs you have your ReadDirectory folder created .
  36. Now go to your start menu -> GitBash -> right click on it -> Send To -> Desktop (create a shortcut) of GitBash on Desktop as shown below :
  37. 0.7

  38. So now on Desktop you will have a GitBash icon .
  39. Now Right Click on the GitBash icon on the desktop and go to properties and in the Start in edit box set the path as : c:xampphtdocs as shown in the image.
  40. 0.8

  41. Now Click on Apply and OK button .
  42. Now start the GitBash application from the desktop and you will have the following screen :
  43. 0.9

  44. Now insert the following command as shown below in the gitbash command prompt window..
  45. Thus after inserting the commands you will have the following view of your window :
  46. 0.10

  47. After you get this , insert further commands in the same command prompt window as given below :
  48. After inserting this command your gitbash command prompt window will have the following look , check whether your username and email you entered has been generated in the list :
  49. 0.11

  50. After this insert the following commands :
  51. You will have the following window :
  52. 0.12

  53. Now go to your github account where you had created the ReadDirectory repository and copy the add origin command and push command and paste it in the gitbash command prompt respectively.
  54. 0.13

  55. So after adding the commands you will be asked for your github username and password ,so you will have the following window :
  56. 0.14

  57. Thus now the push operation is complete, so now we are ready to build our application .
  58. Now go to www.build.phonegap.com and click on Sign in tab present at the right.
  59. 1

  60. After clicking on the Sign in button you will get the next page where you have to click on the Sign in with GitHub button as shown by the arrow head ..
  61. 2

  62. After that you will be navigated to the next page where you have to click on the new app button as shown by the red arrow head.
  63. 3

  64. After clicking on the new app button ,you will get the following window where you have to select the open-source tab and click on the dropdown pointer and select your app as shown in the image :
  65. 4

    NOTE : Here you will have your own application name that is the name given by you while creating the repository.

  66. When you select your app the fetching process will start as shown in the figure :
  67. 5

  68. After the fetching is complete you will get the following window :
  69. 6

  70. Now click on the Ready to Build button as shown by the red arrow in the image and you will get the following screen :
  71. 7

  72. Click on the android icon and you will have the following window popping up to save the apk file.
  73. 8

  74. Now save your apk file and insert it in your android mobile phone and install it ,you will have the application running on your mobile phone
  75. Thus we have successfully learnt how to read directory from sdcard in phonegap .

1 COMMENT

  1. You actually make it seem so easy with your presentation but I find this topic to be actually something which I think I would never
    understand. It seems too complicated and extremely broad for
    me. I am looking forward for your next post, I willl try to get the hang of
    it!

LEAVE A REPLY

Please enter your comment!
Please enter your name here