Wednesday, September 18, 2013

How I built my PC/Android Accessible Database for Butterflies and Moths

I am interested Butterflies and Moths. I like to learn about them. I like to photograph them. I wanted to keep a list of the butterflies and moths I have seen. I wanted to have access to this list on my computers and portable android devices. I began looking around for solutions. I began with Memento - for Android. While this works fine on Android, there is no PC interface. So my search continued. I looked at SailForms as well. It doesn't have a PC interface either. Finally, I settled on creating my own SQLite database and syncing across all my devices using FolderSync. The only downside is that there is no nice and pretty form based interface. But this is not a problem for me. Here's how I developed my database.

1) Create the butterfly/moth database.
    a.There are numerous websites available which will give you lists of butterflies and moths in a particular area. I started with my county. I downloaded the list as a .csv file. Now I am ready to build the database.
    b. I was already familiar with the excellent SQLite manager SQLite Expert Personal. This is my app of choice for SQLite table creation/data entry.
    c. Unfortunately SQLite Expert Personal (free version) doesn't have an import from .cvs function.
    d. I opened the downloaded .cvs file and added extra columns for the things I wanted like location, date sighted, notes, etc. See example below.

        Common Name,Scientific Name,Family,Date Sighted,Location,Notes,Sighted
        Silver-spotted Skipper,Epargyreus clarus,Hesperiidae Skippers,8/25/2013,"170 Ebenzer Rd., Greer, SC 29651",Butterfly Bush. Lots  of them.,TRUE

2) Load the .csv file into the database.
    a. I used SQLite Manager (Another free tool) to create the database. I named the databased "GreenvilleSCButterfliesMoths.sqlite".
    b. Then using SQLite Manager, I created a table ButterfliesMoths and added the columns: Common Name,Scientific Name,Family,Date        

    Sighted,Location,Notes,Sighted. Next I imported the .csv file into the database. Now my db has data!

3) Sync the database using Google Drive and FolderSync.
    a. I created a "Database" folder in my Google Drive folder and put the "GreenvilleSCButterfliesMoths.sqlite file into this folder.
    b. Whenever I view\edit the db on a PC it will be from the Google Drive\Database folder.
    c. For my phone and nexus, I loaded FolderSync from Google Play. FolderSync will sync files from Google Drive to particular files on your Android device. It's fairly straight forward to set up.
    d. Lets say I create a folder named GoogleDriveDatabase on my phone for FolderSync to sync with Google Drive\Database. GoogleDriveDatabase on my phone will now have the latest version of "GreenvilleSCButterfliesMoths.sqlite" FolderSync is bi-directional,  so when I make changes to the database on my phone, the changes will be uploaded to Google Drive. This is fantastic.

4) View/Edit the database on Android devices.
    a. Unfortunately, SQLite Expert is not available as an Android app. The best tool I have found for viewing and editing SQLite db's in  Android is aSQLiteManager.
    b. Using aSQLiteManager I can view and edit my db.

In the end, I have a cloud based db that can be viewed and edited on any PC or Android device. So whether I in the office, at home, or in the field I can make additions to my GreenvilleSCButterfliesMoths database. I like that.