Is it possible to have your Android App write/re-write/overwrite internal classes or enums?

I’m in the process of creating an Android app (in Android Studio) from a Java program that I built. In my program, I have a "write files" class that writes or overwrites internal classes and enums as needed based on data taken in from JSON’s and URL’s. I can figure out how to write to the data/user/0/app/files directory but I cannot figure out how to get the app to re-write its inner-workings…. I know it may not sound like a good idea to some, but it is helpful when you have some enums or interfaces with hundreds or thousands of constants and values. . . If it isn’t possible, can someone guide me to another way of storing data for my app to quick reference? I have constants in interfaces along the line of (for example, x25) int toys = 37 and enums that hold values like:

public enum Dogs{      CORGIE(Breed.CORGIE),     YORKIE(Breed.YORKIE);     private enum Breed{      CORGIE("1", "CORGIE", Size.SMALL, (byte) -33, 200, 2000, 2500, 60.0, (byte) 25,     YORKIE("2", "YORKIE", Size.SMALLER, (byte) -100, 300, 3000, 4500, 150.0, (byte) 10;      private final String BREEDNUM, BREEDNAME;     private final Size BREEDSIZE;     private final Byte FOOD, ENERGY;     private final int SPEED, WEIGHT, HEIGHT;     private final Double ANGER;      Breed(String breedNum, String breedName, Size breedSize, Byte food,             int speed, int weight, int height, double anger, Byte energy) {         BREEDNUM= breedNum;         BREEDNAME = breedName;         BREEDSIZE = breedSize;         FOOD = food;         SPEED = speed;         WEIGHT = weight;         HEIGHT = height;         ANGER = anger;         energy = energy;     } }      private final String BREEDNUM, BREEDNAME;     private final Size BREEDSIZE;     private final Byte FOOD, ENERGY;     private final int SPEED, WEIGHT, HEIGHT;     private final Double ANGER;      Dogs(Breed breed) {         BREEDNUM= breed.breedNum;         BREEDNAME = breed.breedName;         BREEDSIZE = breed.breedSize;         FOOD = breed.food;         SPEED = breed.speed;         WEIGHT = breed.weight;         HEIGHT = breed.height;         ANGER = breed.anger;         energy = breed.energy;     }      public String getBreedNum() {         return BREEDNUM;     }     public String getBreedName() {         return BREEDNAME;     }     // etc...  

(lol best code example I could think of), but I have multiple enums that have anywhere from 100-1,000 values like this. Would storing objects be efficient for the enums? Wouldn’t that take time then for the app to open? I don’t think I want to use something along the lines of assets for constants because the constants the program stores can change depending on the day or week.

I guess I’ve been working on this Java for so long I can’t think of another way to do it. I thought about writing to an internal JSON but am not aware of "instantly" finding a value (ie – not parsing through the entire thing every time).

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.