android


error : couldn't read row 0 , col -1 from cursorWindow make sure the cursor is initialized correctly before accessing data from it?


private void populateQuestionList() {
int QuestionTableSubjectId = questionModelObject.getSubjectId();
ArrayList<QuestionModel> questionArrayList = QuestionManager.getQuestionManager(this).getQuestionBySubjectID(QuestionTableSubjectId);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
for (int i = 0; i < questionArrayList.size(); i++) {
TableRow row = (TableRow) inflater.inflate(R.layout.item_ctrl_list_row, null);
row.setOnClickListener(this);
TextView questionTV = (TextView) row.findViewById(R.id.tv_ctrl_name);
String question = questionArrayList.get(i).getQuestion();
questionTV.setText(question);
row.setTag(questionArrayList.get(i));
questionList.addView(row);
}
}
This method for show question in list calling method getQuestionBySubjectID from data base and the code
public ArrayList<QuestionModel> getQuestionBySubjectID(int subjectId) {
ArrayList<QuestionModel> questionArrayList = new ArrayList();
SQLiteDatabase db = this.getReadableDatabase();
Cursor res = db.rawQuery("select * from Questions where subject_id=" + subjectId, null);
res.moveToFirst();
while (res.isAfterLast() == false) {
QuestionModel questionModelObject = new QuestionModel();
questionModelObject.setQuestionId(res.getInt(res.getColumnIndex("questionId")));
questionModelObject.setQuestion(res.getString(res.getColumnIndex("question")));
questionModelObject.setQuestion(res.getString(res.getColumnIndex("answerOne")));
questionModelObject.setQuestion(res.getString(res.getColumnIndex("answerTwo")));
questionModelObject.setQuestion(res.getString(res.getColumnIndex("answerThree")));
questionModelObject.setQuestion(res.getString(res.getColumnIndex("answerFour")));
questionModelObject.setAnswerOne(res.getString(res.getColumnIndex("correctAnswer")));
questionArrayList.add(questionModelObject);
res.moveToNext();
}
return questionArrayList;
}
Whats wrong with this code? I do not know what is the error (in Cursor).
The problem is that your cursor doesn't contain any result. Might be caused by a wrong query.

Related Links

Firebase Google Keys and OAuthClient messed up
How to give a layout for each tab (Bottom bar)
Android Okhttp do not show/load cached response
No Activity found to handle Intent, when starting Google Maps
Most efficient way to collect and save large amounts of data in background in android
show raspberry pi terminal on the android terminal over usb?
Implementing Click In CardView in RecycleView
Capture intent destination
Firebase working without permission.INTERNET… How?
Android crop camera image
Action posted twice using Handler
Issue with the alarm manager class. I'm setting the alarm but it is not triggered on that time
Extra white space on SlidingTabLayout bar in Android 7.0 N?
onCharacteristicWrite() is being called, but it doesn't always write
Android Multi Screen Incompatibility
Basic Xamarin Android SDK Issue

Categories

HOME
design-patterns
linkedin
nvd3.js
depth
swt
can
bitbucket-api
hpc
zip
python-multithreading
flume
jquery-ui-sortable
windows-ce
openbugs
renjin
job-scheduling
fileserver
template-engine
xmonad
nodemcu
apache2.4
springfox
libigl
r-mice
aggregation
ckfinder
xcode-ui-testing
beautifier
angularjs-components
testcomplete
cognos-bi
reverse
swagger-php
sim-toolkit
sql-server-ce
setup.py
lpsolve
oracle-service-bus
apache-directory
dapper-simplecrud
plan-9
lampp
proget
globalize
google-cse
custom-font
modelsim
libjpeg
monkey
renaming
cvxpy
builtins
microstation
segment-io
vulcanize
jquery-jscrollpane
vorpal.js
php-socket
redis-cluster
jaunt-api
phpgrid
highland.js
dllimport
morton-number
rpart
vacuum
git-ftp
rrule
viewer
browserify-shim
formview
universal-image-loader
trdion2011
cancellation
renderer
authlogic
multitasking
scriptaculous
artemis
solace-mq
jammer
c++builder-xe5
observium
gpars
mvc-editor-templates
asdf
ui-select2
dolby-audio-api
mantle
pstack
pyunit
multiplexing
flex-mobile
gobject-introspection
user-tracking
mysql-error-1205
listactivity
socketserver
undefined-index
data-mapping
skype4java
httpcookie
pbcopy
image-capture

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App