I am currently working on an android project where I would like to store lots of data collected by sensors locally to be able to later push them to my cloudant database for when I do not have access to internet while collecting data.
I am using the git repo https://github.com/cloudant/sync-android
However if the application closes, the data seems to be cleared.
DocumentStore ds = DocumentStore.getInstance(new File(path, "my_document_store"));
When this line is executed, does it create a new file excluding all my previous data after the app is reopened? Or simply my data is cleared when the app is closed?
Is there a way that the data could persist even when the app is closed?
This is the way I store the data.
path = MainActivity.getInstance().getApplicationContext().getDir("documentstores", Context.MODE_PRIVATE);
ds = DocumentStore.getInstance(new File(path, "my_document_store"));
DocumentRevision revision = new DocumentRevision();
revision.setBody(DocumentBodyFactory.create(obj));
Where obj is a hash map for this one measurement and has all the data inside.
When the application is closed then reoppened, I cannot seem to find the object that was just saved.
It looks like you are missing a call to save the revision to the DocumentStore. That would look something like this:
DocumentRevision saved = ds.database().create(revision);