title: How can i resolve the variable i was trying to pass to a cardviewadapter that i tried to extract from sqlite cursor
body: <p>The ide tells me it cannot resolve the symbols that ive put in the ProjectsCardAdapter parameters. the symbols are variables inside a try block that contains string type from cursor</p>
  
  <p>I tried to initialize the string array variables outside the try block but realized i need to getCount how many rows the cursor will have in order to initialize the string arrays.</p>
  
  <pre><code>public class ProjectsFragment extends Fragment {
  
      public ProjectsFragment() {
          // Required empty public constructor
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          RecyclerView projectsRecycler = (RecyclerView) inflater.inflate(
                  R.layout.fragment_projects, container, false);
  
          try {
              SQLiteOpenHelper projectsDBhelper = new ProjectsDBhelper(inflater.getContext());
              SQLiteDatabase db = projectsDBhelper.getReadableDatabase();
              Cursor cursor = db.query("PROJECTS",
                      new String[]{"PROJ_STAGE", "PROJ_BUDGET", "PROJ_LOC", "CLIENT_NAME"}
                      , null
                      , null, null, null, null);
  
              int rowCount = cursor.getCount();
              String[] projStage = new String[rowCount];
              String[] projBudget = new String[rowCount];
              String[] projLoc = new String[rowCount];
              String[] clientName = new String[rowCount];
              int i = 0;
              Float floatBudget;
  
              if (cursor.moveToFirst()) {
  
                  projStage[i] = cursor.getString(0);
                  floatBudget = cursor.getFloat(1);
                  projLoc[i] = cursor.getString(2);
                  clientName[i] = cursor.getString(3);
  
                  projBudget[i] = String.format("%,.2f", floatBudget.toString());
  
              cursor.close();
              db.close();
  
          } catch (SQLiteException e) {
  
              Toast exceptionToast = Toast.makeText(inflater.getContext(), "Database unavailable", Toast.LENGTH_SHORT);
              exceptionToast.show();
  
          }
          //This is the ProjectsCardAdapter that couldnt resolve the symbol
          ProjectsCardAdapter projectsCardAdapter = new ProjectsCardAdapter(projStage, projBudget, projLoc, clientName);
          projectsRecycler.setAdapter(projectsCardAdapter);
          LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
          projectsRecycler.setLayoutManager(layoutManager);
          return projectsRecycler;
      }
  }
  </code></pre>
  
  <p>i wanted to test a cardview displaying a set of texts using data from SQLite but the adapter cant take the variables from cursor</p>