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

ViewPager with ImageView gives “java.lang.OutOfMemoryError: bitmap size exceeds VM budget”
Pick one of the contact numbers
detect Bluetooth Discovery is on?
How to span and stretch columns in Android
Resuming to the main activity
Yahoo messenger API - error when open a long-lived connection for Comet-style notification
How to make an Android progressbar with rounded loaderbar?
ListView is very laggy - Android
How can I use Turkish characters like 'ş ç ı ö' in an Android TextView?
What is this feature of IntelliJ IDEA (set build target in project's properties)?
Loading Image from URL. SkImageDecoder::Factory returned null
Saving Image Files SQL database
Google map is not loading in android samsung ace mobile
TextView background is stretching
Android, Share library dependency
How to delete duplicated database records?

Categories

HOME
django
httparty
design-patterns
gdb
telegram
twig
apache-spark-mllib
requirements
spring-data-redis
error-handling
owl-carousel
database-normalization
tivoli
nsbundle
gembox-spreadsheet
lanczos
arangodb
fosrestbundle
gson
github-enterprise
startup
jxl
heat
bitnami
xmonad
enterprise-miner
solrcloud
undertow
resourcebundle
direct3d11
angular-translate
wcag
sqsh
userdefaults
python-2.6
laravel-eloquent
modalviewcontroller
arduino-ide
batching
sim-toolkit
graphhopper
sessionstorage
odroid
preloader
file-sharing
jquery-ui-draggable
yii2-api
globalize
reportservice2010
identification
singleinstance
oracleclient
skin
check-mk
rackspace-cloud
offline.js
shinobi
seek
watch-os-2
mongodb-php
grass
dynamics-nav-2016
boomerang
toran-proxy
lazybones
dnssec
kubuntu
xmltype
exceldatareader
nodelist
webmatrix-3
sonarqube-5.0
easyrtc
cocos3d
codeplex
vbe
cfcache
gae-quotas
away3d
beaker-testing
scmmanager
actiondispatch
chart-director
virtual-pc
curb
tree-balancing
monotouch.dialog
rmiregistry
predicatebuilder
floating-point-exceptions
stress
flex-mobile
screen-size
promotion-code
mbeans
timthumb
addchild
burndowncharts
django-piston
cuda.net
wysiwym
java1.4
cardspace

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