1

I started learning Java and Android development recently, and I'm learning by building a small app for myself. Nothing fancy, it's just a simple mileage tracker for my car. I know there are tons of them available, but I figured it would be an easy app to learn on.

Anyway, I've reached a point now where I want to dogfood the app, but I want to do it while also adding new features to it. Problem is, the app is using an SQLite database, and when I test new features I have to add / edit / remove records, but I also want to keep these records, since I'm creating them by actually using the app in my day to day life.

How do you usually approach this situation? I figured I have two options:

  1. Dogfood a stable branch/tag of the application, and create a new application from the development branches. Basically I would have two apps, the stable version which I'm currently using, and the development instance, where I can hack and slash as I please.
  2. Use two SQLite databases in the same app, and implement a simple switch between them.

How do you handle this situation?

  • If the problem is just the DB, Android provides an easy way to version them, so that when upgrading the app, the old records can be converted to the new format (see [SQLiteOpenHelper](http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html)). – bigstones Aug 08 '15 at 14:37
  • Yes, but it's not about the DB structure, it's about the actual data. On one hand I want to keep all the records because they represent my actual data, and on the other I have to keep adding, changing and removing records as part of testing new features. – Victor Stanciu Aug 08 '15 at 16:51

1 Answers1

1

You can use Gradle build flavors to create two APK files from the same code base.

The two APK files would have different package name. Different package name means they can be installed on the same phone side by side & they will have different local databases.

productFlavors {
    vanilla {
        packageName "com.example.myapp"
    }

    strawberry {
        packageName "com.example.myapp.dev"
    }
} 

You can find more information about product flavors and overriding resources in this blog post.

LordRaydenMK
  • 166
  • 8