It is something that may seem very new but I have this doubt, I will do it with a simple example:
I have a database with a table that contains, among many other things, a "name" column
When I want to use the name of id 1 many times, what is the best practice?
Option 1: Create a String variable called "name" to make a single query in the database Option 2: Call "name" directly from the database every time it is to be used
I always create a variable to avoid many queries in my database but I don't know if I'm right
String name = appDataBase.tableDao().getName(id);
textView1.setText(name);
textView2.setText("Employee: " + name);
.
.
.
Create a String variable called "name" to make a single query in the database
Call "name" directly from the database every time it is to be used
Get it from the database directly
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments