0

I have the following situation, I have an Android codebase where I read data from a DB on an sdcard. Now Lets say I have two folders mnt/sdcard/folder1 which has 1.sqlite in it and mnt/sdcard/folder2 which has 2.sqlite in it. Is there a way I can build and install two apk's 1.apk and 2.apk which read from the respective folders and databases at runtime? The codebase is the same - just at run time - one of the apk's is called 1.apk which knows it has to read from the first folder and the second from second. And both are installable at the same time.

OR

is there a better way to achieve this ?

Vrashabh Irde
  • 14,129
  • 6
  • 51
  • 103

1 Answers1

0

I'm not entirely clear on what you're trying to do, but the only way to have two versions of your code running on the same device is to have two different package names for the two .apk files.

Put your common code base into a library project, then define two application projects, one for each configuration. Make each application project dependent on the common code base and just define the few things you need that are specific to each configuration.

If you need both applications running at the same time, I think this is the only way to do it. However, if you need an application that can behave selectively one way or the other when it runs, then it sounds like you can just use some run-time flags.

Alternatively, you can make each data set accessible through a service and dynamically attach to the required service at run time. Whether this makes sense depends on what you're trying to accomplish with all this.

EDIT Another approach is to have separate launch icons for the two behaviors, each tied to a different activity in your application. See this thread for more info about this approach.

Community
  • 1
  • 1
Ted Hopp
  • 232,168
  • 48
  • 399
  • 521
  • Well by two versions what I mean is the same codebase say V 1.0 for both apks, but one version reads from folder 1 and is called 1.apk and another one reads from a folder 2 and is called 2.apk . Would your answer change with this info? thanks – Vrashabh Irde Nov 18 '12 at 04:08
  • @Slartibartfast - I added another idea to my answer. – Ted Hopp Nov 18 '12 at 04:12