p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional Android 4 Application Development (http://p2p.wrox.com/forumdisplay.php?f=685)
-   -   Content Provider, LoaderManager (http://p2p.wrox.com/showthread.php?t=93177)

Codex June 29th, 2014 10:39 AM

Content Provider, LoaderManager
 
Hello, i have a counter application, and list of count items in my database. I was using SimpleCursorAdapter with ListActivity and and it was easy to populate items on Adapter. i was doing database operations using sql queries.

Now i switched to LoaderManager and ContentProvider. I read Chapter 8, my PROBLEM is i constructed my content provider, but when i update any data using ContentResolver(contentProvider) , it is tooo slow. I have about 5 items displayed on my screen, each has increase buttons (http://goo.gl/RmnTmO)

So if i click plus button, i update value with value+1. Those are links for my ContentProvider, Database, MainActivity:
https://dl.dropboxusercontent.com/u/...roid/Main.java
https://dl.dropboxusercontent.com/u/.../Database.java
https://dl.dropboxusercontent.com/u/...tProvider.java

HELP with this contentProvider and Asynch LoaderManager thing, they are sooo slow. and i dont want to use depreciated startManagingCursor(cursor);

Kees July 9th, 2014 12:02 PM

Content Provider, LoaderManager
 
Hi,
I am not that familiar with this stuff but don't see an asynchronous loader here, as that restartLoader is called in a new thread.
At the end of onCreate in your main for instance :
Code:

    Thread t = new Thread(new Runnable() {
      public void run() {
              update();
      }
    });
    t.start();
  }
 
  Handler handler = new Handler();
 
  public void update() {
    handler.post(new Runnable() {
      public void run() {
              getSupportLoaderManager().restartLoader(0, null, this);
      }
    });
  }



All times are GMT -4. The time now is 05:38 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.