Skip to content
Advertisement

How can i pass values from sqlite database to viewpager?

There is my model. (Card with two questions)

JavaScript

This is my Activity. Adapter pass values from ArrayList to the ViewPager.

JavaScript

In this class I create DataBase and try to pass values from cursor to ArrayList in MainActivity, but, when I start to debug, the debugger shows me that ArrayList in MainActivity is not filled with values. What I should do to fix this??

JavaScript

Just in case, I will attach the Fragment code

JavaScript

Advertisement

Answer

SQLiteOpenHelper has its own internal SQLiteDatabase. You can get the database from the helper via a few get functions like getWritableDatabase, use those instead of your own SQLiteDatabase cardsDatabase; which at no point in the provided code are you initializing it, meaning your probably getting a NPE whenever you use the DatabaseManager, thus the ArrayList won’t fill.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement