0

I am trying to get all items on my db while the first step is my db is empty and after that I insert some items from my db .I am inserting correctly(dont have any errors and inserting num is bigger that 0). but after the inserting when trying to get all items back from the db get null on dbAdper.getAllTitles();

here is my code

public ArrayList<Object> getWantedItemsList(Context context,String item,String item2,String item3,String item4){
        ArrayList<Object> ListRssLinkAndTitle=new ArrayList<Object>();
        DBAdapter dbAdper=new DBAdapter(context);
        Cursor CursorDb =null;
        try
        {
            dbAdper.open();
            dbAdper.drop();
            dbAdper.createTable();
            dbAdper.insertTitle(context,"Ynet", "http://www.ynet.co.il/Integration/StoryRss2.xml", "rtl",null);
            dbAdper.insertTitle(context,"BBC", "http://feeds.bbci.co.uk/news/world/us_and_canada/rss.xml", "rtl",null);
            CursorDb =dbAdper.getAllTitles();
            CursorDb.moveToFirst();
            if (CursorDb.getCount()>0)
                do
                { 
                    ListRssLinkAndTitle.add(new rssLinkAndTitle(CursorDb.getString(CursorDb.getColumnIndex(item)),CursorDb.getString(CursorDb.getColumnIndex(item2)),CursorDb.getString(CursorDb.getColumnIndex(item3)),CursorDb.getBlob(CursorDb.getColumnIndex(item4))));
                }
                while(CursorDb.moveToNext());
        }
        finally{
            if (CursorDb.equals("null"))
            CursorDb.close();
            dbAdper.close();
            return ListRssLinkAndTitle;
        }

    }

and the method that get null is

public Cursor getAllTitles()  throws SQLException
    {
        return db.query(DATABASE_TABLE, new String[] {
                KEY_ROWID, 
                link,
                RssTitle,
                Rtl,
                image
        }, 
        null, 
        null, 
        null, 
        null,
        null
                );
    }
1
  • add some more code of DatabaseAdapter code like constructor part Commented Jan 5, 2013 at 9:55

1 Answer 1

1

You haven't created Database Object db in your database helper class. Please make sure that you are not closing the database after inserting the Values into table.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.