Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

[VS] Copy existing app, but with different SQlite local DB data

iamnotafrediamnotafred Member ✭✭
edited August 27 in Xamarin.Forms

I created beta app for Android with local SQlite DB data.
I would like to create copy of this app for production, but with a different SQlite DB data. Same models, but different data source. I don't want to share DB between beta and production-ready app.

How to achieve this?

Best Answers

  • iamnotafrediamnotafred Member ✭✭
    edited August 27 Accepted Answer

    Do I only need to change the name of the db in my Init method?

    public void Init()
          {
    
                string dbPath = Path.Combine(
                     Environment.GetFolderPath(Environment.SpecialFolder.Personal),
                     "this-is-my-db.db3");
                dbSQLite = new SQLiteConnection(dbPath);
    
            }
    
    

    How about other steps? How to correctly copy whole project?

  • iamnotafrediamnotafred Member ✭✭
    Accepted Answer

    I solved this error by moving the project folder to the default repos path. This is strange, because other projects worked well in my projects folder.

Answers

  • iamnotafrediamnotafred Member ✭✭
    edited August 27 Accepted Answer

    Do I only need to change the name of the db in my Init method?

    public void Init()
          {
    
                string dbPath = Path.Combine(
                     Environment.GetFolderPath(Environment.SpecialFolder.Personal),
                     "this-is-my-db.db3");
                dbSQLite = new SQLiteConnection(dbPath);
    
            }
    
    

    How about other steps? How to correctly copy whole project?

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    Do beta and production-ready app install same android device?

    If beta and production-ready app install same android device, you need to create a new sqliteDB name.

    If not, you do not create a new sqlite DB name, when you install production-ready app in a new android device at the first time, it will create a new DB file.

  • iamnotafrediamnotafred Member ✭✭
    edited August 27

    Beta and production-ready app install on the same android device.

    Is the solution I provided correct?

    public void Init()
          {
    
                string dbPath = Path.Combine(
                     Environment.GetFolderPath(Environment.SpecialFolder.Personal),
                     "this-is-my-db.db3");
                dbSQLite = new SQLiteConnection(dbPath);
    
            }
    
    

    I only need to change the name of the DB? How about rest of the files?
    Is there a proper solution how to copy existing project? When I copy and paste project and change solution name, it compiles as the same app...
    So how should I properly clone app which should exist as separate app?

  • LardeCristoLardeCristo Member ✭✭
    public void Init()
    {
        string dbName;
        if( beta==true) 
            dbName = "this_beta_db.db3";
        else
            dbName = "this_official_db.db3";
    ...
    ...
    }
    
  • LeonLuLeonLu Member, Xamarin Team Xamurai

    Are there any update for this issue? If reply is helpful, please accpet it as answer.

  • iamnotafrediamnotafred Member ✭✭
    edited August 28

    I need to have 2 seperate applications. Not one.
    What steps should I follow to achieve this?
    I was doing the folllowing:
    1. Copy the BetaApp folder.
    2. Paste the BetaApp folder into new ProductionReadyApp folder.
    3. Visual Studio -> Open project -> ProductionReadyApp -> ProductionReadyApp.sln
    4. Change solution name to ProductionReadyApp.
    5. Change DB name inside file. (it's not important right now)

    But 1-3 steps didn't work! It launch the same project as BetaApp after compilation.
    With the step 4 I got errors...

  • DirkWilhelmDirkWilhelm USMember ✭✭✭✭✭

    You need to change the package name (on Android) or the bundle identifier ( for iOS) if you want it to be a seperate app.

    You can find these settings in the manifest section of the properties of the platform projects.

  • iamnotafrediamnotafred Member ✭✭
    edited August 28

    I did and I got error: Unable to remove directory obj\Debug\81\android\bin\classes

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    Do you change the package name in the AndroidManifest.xml?

    After that, please re-build your project.

  • iamnotafrediamnotafred Member ✭✭
    edited August 31

    Yes. I did this step, and it didn't work out. I tried to delete classes folder manually, but after that I receive Javac error.

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    I tried to delete classes folder manually, but after that I receive Javac error.

    Where is this classes folder? In the project folder? If so, you cannot delete it, you just could delete the bin and obj folder.

  • iamnotafrediamnotafred Member ✭✭

    This is really frustrating...
    Cloning project should be as easy as one button click.

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    You can take a feature request for your needs.
    https://github.com/xamarin/Xamarin.Forms/issues

  • iamnotafrediamnotafred Member ✭✭
    Accepted Answer

    I solved this error by moving the project folder to the default repos path. This is strange, because other projects worked well in my projects folder.

Sign In or Register to comment.