Android, Best way to provide app specific constants in a library project?

后端 未结 3 1803
走了就别回头了
走了就别回头了 2021-02-13 12:26

I am creating a library project for a number of android apps. The apps all have some common functionality that I wish to include in the library project but the library project f

3条回答
  •  日久生厌
    2021-02-13 12:58

    Option #1 Extend your AppConstants class in each project

    Better Option#2 Use XML resources to define the constants

    
    
    6
    
    

    then you can retrieve them by

    Context.getResources().getInteger(R.integer.app_id);
    

    add the xml file to your resources in each project with only the values you need different

提交回复
热议问题