Returning amount of Sqlite records and displaying in TextView

1

I have an application and I need to display in%% of the amount of records stored.

public int contagem(){
    createBank = new CreateBank(this);
    connecting = createBank.getReadableDatabase();
    String cursor = "SELECT * FROM "+TABELA;
    int contador = connecting.rawQuery(cursor, null).getCount();
    TextView txtContagem = (TextView) findViewById(R.id.txtContagem);
    txtContagem.setText(contador);
    return contador;
}

2018-10-24 17:09:20.221 30170-30170/com.example.leandroramos.qualidade E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.leandroramos.qualidade, PID: 30170
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
    at com.example.leandroramos.qualidade.Qualidade.WorkSpace.contagem(WorkSpace.java:216)
    at com.example.leandroramos.qualidade.Qualidade.WorkSpace$1.onClick(WorkSpace.java:148)
    at android.view.View.performClick(View.java:6256)
    at android.view.View$PerformClick.run(View.java:24717)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:169)
    at android.app.ActivityThread.main(ActivityThread.java:6568)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
    
asked by anonymous 24.10.2018 / 20:27

0 answers