0

I have a listview which is supposed to show 25 rows of data but with the images in the database, the query has exceeded 1mb when reach 13 rows and as I quote from here

Android SQL Lite fail to grow

The CursorWindow class only supports reading 1MB of data per query:

#define MAX_WINDOW_SIZE (1024 * 1024)

so I thought maybe it would be better if I can split query up into smaller queries and run them one at a time and then show the items in the listview.

here are my codes

mDB = new ChannelDB(this);

        String[] columns = {mDB.KEY_ID, mDB.KEY_POSTER, mDB.KEY_CHANNEL, mDB.KEY_PATH, mDB.KEY_DBLINK};
        String   table   = mDB.channelS_TABLE;

        c = mDB.getHandle().query(table, columns, null, null, null, null, null);

        startManagingCursor(c);

        SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
                R.layout.channelview,
                c,
                new String[] {mDB.KEY_POSTER, mDB.KEY_CHANNEL, mDB.KEY_DBLINK},
                new int[] {R.id.poster, R.id.channel, R.id.douban});

        adapter.setViewBinder(new ChannelViewBinder(this));

        channellist.setAdapter(adapter);

        channellist.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                c.moveToPosition(position);
                String xPath=c.getString(c.getColumnIndex(mDB.KEY_PATH));
                String xName=c.getString(c.getColumnIndex(mDB.KEY_CHANNEL));
                String xDBlink=c.getString(c.getColumnIndex(mDB.KEY_DBLINK));
                Intent intent = new Intent();
                intent.setClass(HDtvs.this,Showlist.class);
                intent .putExtra("path",xPath);
                Log.i("HDtvs", "path = " + xPath);
                intent .putExtra("cname",xName);
                intent .putExtra("dblink",xDBlink);
                startActivity(intent);
            }
        }); 

and as you see, a mDB.KEY_POSTER is an image stocked in the database. I tried to save the path into the database and that didn't work, if you can provide a way to do that with an example, that will be equally helpful,thx

Community
  • 1
  • 1
oratis
  • 818
  • 1
  • 9
  • 29

1 Answers1

0

Use limit and offset to page through the data.

Tom
  • 43,583
  • 4
  • 41
  • 61