Basically, I can insert into my database and view all the results using the below method and a SimpleCursorAdapter displaying to a ListView - works totally fine.
// Returns a Cursor containing all JSON strings
public Cursor getAllJSONstrings()
{
// Return all JSONstrings ordered by COLUMN_ID
return ssDatabase.query(TABLE_ROUTINES, new String[] {COLUMN_ROWID, COLUMN_JSON}, null, null, null, null, COLUMN_ROWID);
}
However, the following method gives nothing less than the NullPointerException
every time I query.
The id LogCat tag shows the tag as being what it should be, 1 for the first item etc.
// Return one JSONstring in String form
public String getJSONstring(long id)
{
Log.i(TAG, "getJSONstringStart... id=" + id);
Cursor cursor;
Log.i(TAG, "Cursor defined");
/****** NullPointerException LINE ******/
cursor = ssDatabase.query(TABLE_ROUTINES, null, "_id=" + id, null, null, null, null);
Log.i(TAG, "Exceed Cursor");
int index = cursor.getColumnIndex(COLUMN_JSON);
Log.i(TAG, "index=" + index);
return cursor.getString(index);
}
For what it's worth, this method getJSONString(long id) is being executed in an AsyncTask. The id it refers to is the id in an OnItemClickListeners onItemClick method.
Any help would be very appreciated, my head has gone square!
Cheers!