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

  • Home
  • SEARCH
  • 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 7014425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:31:10+00:00 2026-05-27T22:31:10+00:00

Not all that sure how I would describe this question, so I’ll jump right

  • 0

Not all that sure how I would describe this question, so I’ll jump right into the example code.

I have a Constants.java

   package com.t3hh4xx0r.poc;


public class Constants {

    //RootzWiki Device Forum Constants
    public static final String RWFORUM = "http://rootzwiki.com/forum/";
    public static final String TORO = "362-cdma-galaxy-nexus-developer-forum";

    public static String DEVICE;
}

In trying to determine the device type, I use this method.

public void getDevice() {
    Constants.DEVICE = android.os.Build.DEVICE.toUpperCase();
    String thread = Constants.(Constants.DEVICE);
}

Thats not correct though, but thats how I would think it would have worked.

Im setting the Constants.DEVICE to TORO in my case on the Galaxy Nexus. I want to then set the thread String to Constants.TORO.

I dont think I’m explaining this well, but you shoudl be able to understand what I’m trying to do fromt he example code. I want

Constants.(VALUE OF WHAT CONSTANTS.DEVICE IS) set for the String thread.

Another way to put it,

I want to get Constants.(//value of android.os.Build.DEVICE.toUpperCase())

I apologies for the poorly worded question, i dont know of any better way to explain what Im trying to achieve.

Im trying to determine the thread based on the device type. I could go in and do an

if (Constants.DEVICE.equals("TORO"){
    String thread = Constants.TORO;
}

But I plan on adding a lot more device options in the future and would like to make it as easy as adding a string to the Constants.java rather than having to add another if clause.

  • 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-27T22:31:10+00:00Added an answer on May 27, 2026 at 10:31 pm

    I would suggest using an enum instead of just strings – then you can use:

    String name = android.os.Build.DEVICE.toUpperCase();
    // DeviceType is the new enum
    DeviceType type = Enum.valueOf(DeviceType.class, name);
    

    You can put the value of the string in a field for the enum, and expose it via a property:

    public enum DeviceType {
        RWFORUM("http://rootzwiki.com/forum/"),
        TORO("362-cdma-galaxy-nexus-developer-forum");
    
        private final String forumUrl;
    
        private DeviceType(String forumUrl) {
            this.forumUrl = forumUrl;
        }
    
        public String getForumUrl() {
            return forumUrl;
        }
    }
    

    (I’m guessing at the meaning of the string value – not a great guess, but hopefully it gives the right idea so you can make your actual code more meaningful.)

    EDIT: Or to use a map:

    Map<String, String> deviceToForumMap = new HashMap<String, String>();
    deviceToForumMap.put("RWFORUM", "http://rootzwiki.com/forum/");
    deviceToForumMap.put("TORO", "362-cdma-galaxy-nexus-developer-forum");
    
    ...
    
    String forum = deviceToForumMap.get(android.os.Build.DEVICE.toUpperCase());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off I'm not sure that's the proper title for this question but hopefully
i m not sure how to describe this as i m new with all
I'm not all that familiar with jquery so I'm not quite sure how to
ok i found this for removing all 'junk' that is not a number from
I would like to take a field and replace all characters that are not
Sorry for the poor question wording I wasn't sure how to describe this. I
Sorry about the title, not sure how to describe without example. I trying to
I'm not sure the best way to describe what it is that I'm trying
This is a question that I have been pondering for a long time ,
Apologies for the poor question title - I'm not sure how to describe what

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.