I'm trying to view a progress bar in my Android App that follows the filling of the database with some data and when it's complete the progress bar should view "100%" or just that the loading of the data is complete. I would use this Progress bar in my app.
While here is my class with all the algorithms with which i get data from a HTML site and put them in to SQLite. Do you have any suggestion on how can i implement a progress bar with it?
public class articoli extends AppCompatActivity {
String htmlresultart;
Integer DaDoveParto = 0;
Integer DoveMiFermo = 0;
Integer QuanteRighe = 0;
Integer QuantiCampi = 0;
String appCAMPOart = "";
String[] appBODYart = new String[9];
DataBaseHandler myDB;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_articoli);
myDB = DataBaseHandler.getInstance(this);
myDB.delete();
getHTMLArticoli();
}
private void getHTMLArticoli(){
Ion.with(getApplicationContext())
.load("WEPPAGEIP")
.asString()
.setCallback(new FutureCallback<String>() {
@SuppressLint("SetTextI18n")
@Override
public void onCompleted(Exception e, String result) {
htmlresultart = result;
htmlresultart = htmlresultart.replace("</td>", "\n");
getBodyArticoli();
}
});
}
private void getBodyArticoli(){
DaDoveParto = Integer.valueOf(String.valueOf(htmlresultart.indexOf("TBLCRP")));
DoveMiFermo = Integer.valueOf(String.valueOf(htmlresultart.indexOf("</form>")));
if(DaDoveParto == 0){
Toast.makeText(this,"NESSUN DATO TROVATO",Toast.LENGTH_SHORT).show();
}else
{
Integer i;
Integer j;
Integer CONTACAMPO = 0;
for( i = DaDoveParto ; i <= DoveMiFermo ; i++){
if( htmlresultart.substring(i, i + 4).equals("<td>")){
i += 4;
for (j = i; j <= DoveMiFermo ; j++){
if(htmlresultart.substring(j, j + 1).equals("\n")){
appBODYart[CONTACAMPO] = htmlresultart.substring(i, i + (j - i));
if(appBODYart[CONTACAMPO].equals("(null)")){
appBODYart[CONTACAMPO] = "";
}
CONTACAMPO += 1;
if(CONTACAMPO.equals(QuantiCampi)){
CONTACAMPO = 0;
myDB.insertArtServer(appBODYart[0], appBODYart[1], appBODYart[2], appBODYart[3], appBODYart[4], appBODYart[5],
appBODYart[6], appBODYart[7], appBODYart[8]);
}
break;
}
}
}
}
}
}
}