delight-im / Android-DDP

[UNMAINTAINED] Meteor's Distributed Data Protocol (DDP) for clients on Android
Apache License 2.0
274 stars 54 forks source link

Documents are replicating each and every time, why? #105

Closed prasannakumark closed 8 years ago

prasannakumark commented 8 years ago

Hi All,

I'v question about why meteor will replicating documents for each and every time when ever i run application. Let me explain you the use case, I've 2500 documents in my meteor server, of course i agree that if app is installing the first time it will take few mints of time. But currently when ever run the application taking same time and again replicating each time, why ?. Here is my code,

Meteor mMeteor = new Meteor(context, AppConstant.meteorUrl, new InMemoryDatabase());
            mMeteor.connect();
mMeteor.subscribe("testCollection", null, new SubscribeListener() {
                @Override
                public void onSuccess() {

                }

                @Override
                public void onError(String error, String reason, String details) {
                    Toast.makeText(context, "testCollection Subcribe error", Toast.LENGTH_SHORT).show();
                }
            }); 

Any solutions how I can solve this are the problems and how I can achieve this feature in meteor. Before, I would like to thanks for you suggestion.

ocram commented 8 years ago

Thanks for your feature request!

I guess what you want is persistent storage on disk so that the documents don't have to be re-loaded whenever you open your app the next time. Is this correct?

Right now, there is no persistent storage available. As you can see from the database name, InMemoryDatabase, the database is stored in memory only and thus goes away when your application is killed. The next time you open your app, the database will be empty again.

If you wanted to keep the documents, you'd have to create a new class implementing the Database interface and pass an instance of that new class to the constructor (see your code excerpt) instead of new InMemoryDatabase().

The documents could be stored in an SQLite database, for example.

Of course, you don't have to do all that. If you just need some of your own documents to be around after restarting your app, you may also get the collections or documents via the database access methods and then save them to a database or file yourself. The next time you open your app, you load the stored data from the database or file.

Hope that helps! Sorry there's no easier solution available yet.