How to insert via SQLite a data in its respective Acitivity

2

I'm doing an android application and inside it has a fixed listiView sent by an array of string for example

 String[] servicos = {"Eletricista", "Pedreiro", "Pintor", "Encanador", "Arquiteto", "Engenheiro", "Marcineiro", "Serralheiro"};

In my application I would like the user to work within their respective area if they registered and were added within their area, I already have the form ready

Situation example - > an electrician registers and his name is played directly on the Activity of the electrician.

How do I sqlite get the data and play within its Activity .

The project is of course. I'm sorry if I said bullshit I'm a beginner in android

    
asked by anonymous 14.11.2017 / 21:46

1 answer

2

it makes several else if or switch case that sent it to its respective activity, in this example I suppose that the register is being done in MainActivity :

Intent it;
switch(tipo) {
    case "encanador": 
        it = new Intent(MainActivity.this, Encanador.class);
        startActivity(it);
        break;
    case "eletricista":
        it = new Intent(MainActivity.this, Eletricista.class);
        startActivity(it);
        break;
}

Serve?

I know there is a possibility of using Class.forName(tipo) instead of using Classe.class , being type a String , but I do not know how to use

Edit:

Complementing with @ramaral's answer:

try {
    Class classe = Class.forName("nome.do.pacote." + classe);
    startActivity(new Intent(MainActivity.this, classe));
} catch (ClassNotFoundException e) {
    e.printStackTrace();
}

Being classe the variable registered in the bank

Remembering that the names of the classes must be the same as the ones registered

    
14.11.2017 / 21:58