Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6988423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:04:47+00:00 2026-05-27T19:04:47+00:00

I have an Android app project that contains all of my code. I’ve made

  • 0

I have an Android app project that contains all of my code. I’ve made this “app” a Library project as defined here at android.developer.com..

Consequently, I have made two new Android projects which utilize this library project. The new package names for each of the new projects are:

com.myapps.freeapp
com.myapps.paidapp

As you can probably see, I am trying to publish free and paid versions of the app.

What is the best way to tell the library project whether the installed app is the free version or paid version?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:04:48+00:00Added an answer on May 27, 2026 at 7:04 pm

    This is from my blog post that describes how to build a free / paid version using a library project.

    Generally, you’ll create three projects; a free project, a paid project and a library project.

    You’ll then create a Build.java file in your library project such as this:

    public class Build {
        public final static int FREE = 1;
        public final static int PAID = 2;
        public static int getBuild(Context context){
            return context.getResources().getInteger(R.integer.build);
        }
    }
    

    Now, you’ll create an build.xml resource in each of your projects:

    [library]/resources/values/build.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <resources>
        <integer name="build">0</integer>
    </resources>
    

    [free]/resources/values/build.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <resources>
        <integer name="build">1</integer>
    </resources>
    

    [paid]/resources/values/build.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <resources>
        <integer name="build">2</integer>
    </resources>
    

    You will then be able to check for the version at run time:

    if (Build.getBuild(context) == Build.FREE){
       // Do the free stuff
    } else {
       // Do the paid stuff
    }
    

    The blog post details the exact steps necessary to create the projects from scratch at the Linux command line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Android project that branched into three different applications, app-1 , app-2
I have a library android project Library (with activities and all) and a normal
I'm making a paid/free version of my app so have a 'Library Project' that
I have a working Android tuner project app that I want to use as
I've got a native Android app that contains a WebView. All my HTML, js
I have a class that extends android.app.Dialog, the layout is done in an xml
I have a free android app that I want to now distribute as free
I am writing an Android app. I have an activity in my main project
I have two projects: 1- Project A: Which is the Android app project. 2-
I have a android app project in Eclipse, and in my activity containing a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.