File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Android and the fly likes json and phonegap (cordova) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "json and phonegap (cordova)" Watch "json and phonegap (cordova)" New topic

json and phonegap (cordova)

Lou Emmelot

Joined: May 14, 2012
Posts: 3
Hello Damon/Sebastien,
I'am new in Java/Javascript but I learned a lot reading and probing your book 'Pro Android Web Apps'. Just What I needed.
Hoping to produce a webapp on the base of your TODOLIST I had it working in my browser as well in my android as a web page.
So I tried to make a real native .apk with the Phonegap framework in Eclipse. That also worked with the exception that the json database does not respond.
I can see that something is happening in Googles appengine, but only when I load the index.html from the appengine url. The queries are there (I can see the GET) but nothing is produced.

This is the java in Eclipse:

import android.os.Bundle;
import org.apache.cordova.*;

public class BuzzActivity extends DroidGap {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
// super.loadUrl("file:///android_asset/www/index.html");
// here I load the index.html from the server = not what should be in a native app!! But I do not know otherwise.
// When I do this WITHOUT Phonegap everything is fine....


This is from your TODOLIST.JS a little adapted:

function cloudQuery() {

plateName = $.jStorage.get("platename");
countrySelect = $.jStorage.get("country");
stateSelect = $.jStorage.get("state");

if (plateName) params = { cond: "name.eq." + plateName };
else params = { sort: "_createdAt.desc", limit: 100 };

$.get("/_je/tasks" + countrySelect + stateSelect, params, function (currentTasks) {
var listHtml = '';

// iterate through the current tasks
for (var ii = 0; ii < currentTasks.length; ii++) {
// add the list item for the task
listHtml += "<li id='task_00'><ul><li></li></ul>" +
"<div class='task-header'>" + currentTasks[ii].name + "</div>" +
"<div class='task-details'>" + currentTasks[ii].description + "<br />" +
"<a href='#' class='task-complete right'></a> " + "</div>" +
"<div class='task-details'>" + currentTasks[ii].due + "</div>" +
} // for
if (listHtml == "") {
if (!plateName) {
listHtml = "<li id='task_00'><ul><li></li></ul>" +
"<div'> NOTHING found: This could be a good thing. !!</div>" +
else {
listHtml = "<li id='task_00'><ul><li></li></ul>" +
"<div'> NOTHING in the Cloud for: " + plateName + " !!</div>" +
else {

// refresh the task list display
jQuery("ul#cloudlist li").click(function () {

jQuery("ul#cloudlist a.task-complete").click(function () {
// complete the task
alert("Delete this Buzz.");


I think that JSON is not working together with Phonegap.
Now I read something that should be used JSONP, but all I can find is to use JSONP with $.ajax.
Alltogether it is not working at all while it costed me weeks to find all the tools to get so far..........

Can you help me out?

Thank you.

I agree. Here's the link:
subject: json and phonegap (cordova)
It's not a secret anymore!