int x; //this gets the number of days left. int y = 100; int z; //final result public void progressBar1() { ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBarId); String[] projection = { HabitTable.COLUMN_NAME}; Cursor cursor = getContentResolver().query(uri, projection, null, null, null); x = cursor.getString(cursor .getColumnIndexOrThrow(HabitTable.DAYSLEFT); int z = 0; if (x == 0) { z = 100; } else { z = 100/(1+x) } }