Dear all,
I am new on App42. For POC, I move my Parse.com data to App42.
Now my data is in storage and i easy get my document by using findAllDocuments.
I my mobile app i am searching all documents and get a value of key and fill a Spinner (dropdown) in my mobile app.
Here is my code. I can not get all the documents :( Is the servıce has any limitation ?
StorageService storageService = App42API.buildStorageService();
HashMap<String, String> otherMetaHeaders = new HashMap<String, String>();
otherMetaHeaders.put("orderByAscending", "Brand");
String dbName = "mydb";
String collectionName = "CarBrand";
storageService.setOtherMetaHeaders(otherMetaHeaders);
App42CacheManager.setPolicy(App42CacheManager.Policy.CACHE_FIRST);
App42CacheManager.setExpiryInMinutes(3600); //1 hour
storageService.findAllDocuments(dbName, collectionName, new App42CallBack() {
public void onSuccess(Object response) {
Storage storage = (Storage) response;
ArrayList<Storage.JSONDocument> jsonDocList = storage.getJsonDocList();
ArrayList<String> brandlist = new ArrayList<>();
final ArrayAdapter adapter = new ArrayAdapter(
getActivity().getApplicationContext(), R.layout.spinner_lay, brandlist );
for (int i = 0; i < jsonDocList.size(); i++) {
try {
JSONObject jsonObject = new JSONObject(jsonDocList.get(i).getJsonDoc());
System.out.println("API42 BRAND " + jsonObject.getString("Brand"));
brandlist.add(jsonObject.getString("Brand"));
} catch (JSONException e) {
e.printStackTrace();
System.out.println("Exception felan creating name" + e.getMessage());
}
}
try {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
markalar.setAdapter(adapter);
}
});
} catch (Exception ex) {
System.out.println("Exception while creating array" + ex.getMessage());
}
}
public void onException(Exception ex) {
System.out.println("Exception Message" + ex.getMessage());
}
});