title: Creating and Storing Log File on device in Android
body: <p>I am planning to automate the testing of an application by creating a log to store some results of execution of the app and latter on parse it using a piece of python code and plot a graph.</p>
  
  <p>The application is a WiFi fingerprinter i.e it collects info such as mac id, rss(recieved signal strength and rank(normalized rss) about the wifi devices in the surrounding environment. So to test this application I would have to take it to the location and record the results(as of now manually). So logcat wouldn't serve the purpose.</p>
  
  <p>Automation requires
  1. Storing the log in the device
  2. Access to the log file in the system through usb</p>
  
  <p>Format of the Log file:</p>
  
  <pre><code>Snapshot: 1
  Fingerprint: 1, Rank: 0.23424, Boolean: true
  Fingerprint: 2, Rank: 0.42344, Boolean: false
  Fingerprint: 3, Rank: 0.23425, Boolean: true
  
  Snapshot: 2
  Fingerprint: 1, Rank: 0.75654, Boolean: false
  Fingerprint: 2, Rank: 0.23456, Boolean: true
  Fingerprint: 3, Rank: 0.89423, Boolean: true 
  
  ................
  </code></pre>
  
  <p>Now I know there are basically 3 approaches for persistent storage(SharedPrefs wouldn't suit this scenario anyway). I tried Internal Storage, but even after setting the mode of the file as <code>MODE_WORLD_READABLE</code> it was impossible to <a href="https://stackoverflow.com/questions/5715556/cant-find-the-file-stored-on-internal-storage-of-device-on-file-explorer">read the file using Device File Explorer in Eclipse</a>. </p>
  
  <p>I am still wary of using external storage for storing the log. Any tutorial on how to write to a file in usb of the device will definitely help.</p>
  
  <p>I thought of structuring the data to be stored so as to use SQLite for storage. But this establishing many unnecessary relations(foreign and domestic) between data and make it complex. If there is no way around, then <a href="https://stackoverflow.com/questions/407202/what-was-the-scary-code-comment-about-dragons">here be dragons</a>.</p>
  
  <p>Basically I want to write to a file(easier I suppose) in the device and latter on read it in my system by connecting to it via usb. Any help on how to do it would be much appreciated.</p>