Note that there are some explanatory texts on larger screens.

plurals
  1. POcan some 1 point out the null pointer exception
    text
    copied!<p>I have edited the code and now the null pointer error is pointing inside the for loop their are less errors than before but i still dont't know why a nullpointer is called.</p> <pre><code> public class searchlist extends ListActivity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); new loadSomeStuff().execute(); } public class loadSomeStuff extends AsyncTask&lt;String, Integer, String[]&gt; { ProgressDialog dialog; protected void onPreExecute() { dialog = new ProgressDialog(searchlist.this); dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); dialog.setMax(100); dialog.show(); } @Override protected String[] doInBackground(String... arg0) { // TODO Auto-generated method stub for(int i =0; i&lt;20; i++) { publishProgress(5); try { Thread.sleep(80); } catch(InterruptedException e) { e.printStackTrace(); } } dialog.dismiss(); int loops = search_page.returnlooped(); int[] teacup = search_page.returnNumArray(); sqlStuff searching = new sqlStuff(searchlist.this); String[] IDSysNames = searching.getIDSysName(); searching.close(); String[] resultList = new String[loops]; for(int i=0; i &lt; loops; i++ ) { if(IDSysNames[teacup[i]] != null) { resultList[i].equals(IDSysNames[teacup[i]]); } } setListAdapter(new ArrayAdapter&lt;String&gt;(searchlist.this, android.R.layout.simple_list_item_1, resultList)); return null; } protected void onProgressUpdate(Integer...progress) { dialog.incrementProgressBy(progress[0]); } } @Override public void onListItemClick(ListView l, View v, int position, long id){ //TODO Auto-generated method stub super.onListItemClick(l, v, position, id); //String Pos = resultList[position]; Intent ourIntent = new Intent("com.MC.ChemPal.RESULT2"); startActivity(ourIntent); } } </code></pre> <p>The method used within the code above is below .</p> <pre><code>public String[] getIDSysName() { String[] result = new String[0]; try { String[] columns = new String[] {KEY_SYSNAME}; Cursor c = ChemPal.query(DATABASE_TABLE, columns, null, null, null, null, null); Log.d("SqlDStuff", "Cursor count: "+c.getCount()); int iSysName = c.getColumnIndex(KEY_SYSNAME); int i = 0; for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){ i++; } result = new String[i]; i = 0; for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){ result[i] = c.getString(iSysName); i++; } } catch(Exception e) { } return result; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload