1. Mobile Application Development
T. S. Indi, IT Department, WIT Solapur Page 1
Handout#8
Problem Statement: Design and implement an application to read and
write contents to Flat File on
(i) internal memory of mobile device and
(ii) external memory (SD card) of mobile device.
Design:
Steps:
1) Design an app to read and write contents to flat file on internal
memory or external memory of mobile device.
2) Design layout with two TextView, two EditText, three and two
buttons “ReadFromFile” & “WritetoFile”.
3) Write to file Operation: User enters text into “Input Text” editText
component and click on “WriteToFile” button to write data file which
is create and saved on internal memory or external memory of
mobile device.
2. Mobile Application Development
T. S. Indi, IT Department, WIT Solapur Page 2
4) Read form file Operation: User clicks on “ReadFromFile” button and
contents from file, saved on internal memory or external memory of
mobile device, should be displayed in “Text in File” editText box.
5) Name of File on which read and write operations are performed is
constant in code.
(i) Read & Write to File saved into internal memory of device:
In this case, text file is created inside datadata<package-name>
folder. In below snapshot project package name is “com.example.flatfile”
and text file name is “userinput.txt”, therefore file is created inside
“datadatacom.example.flatfilefiles” folder.
Click on DDMS (Dalvik Debug Monitor Server) option [as shown in
Fig.8.1] on top right of “Eclipse ADT” window to view file explore [as
shown in Fig 8.2, Fig 8.3].
Figure: 8.1 Select DDMS option
3. Mobile Application Development
T. S. Indi, IT Department, WIT Solapur Page 3
Figure: 8.2 DDMS File Explore to view “datadata” folder
Figure: 8.3 DDMS File Explore to view
“datadatacom.example.flatfilefiles” folder
(ii) Read & Write to File saved into external memory of device:
4. Mobile Application Development
T. S. Indi, IT Department, WIT Solapur Page 4
In this case, text file is created inside mntsdcardFlatFileAppFolder. In
snapshot [Fig 8.4], text file name is “userinput.txt is created inside
“mntsdcardFlatFileAppFolder” folder.
Figure: 8.4 DDMS File Explore to view “mntsdcardFlatFile”
folder
[Reference: Book -“Mobile Apps Development” by Anubhav Pradhan, Anil V Deshpande]