Java Code Examples for android.database.Cursor.close()

The following are Jave code examples for showing how to use close() of the android.database.Cursor class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Renrentou   File: ConvertUtils.java   Source Code and License Vote up 6 votes
private static String _queryPathFromMediaStore(Context context, Uri uri, String selection, String[] selectionArgs) {
    String filePath = null;
    try {
        String[] projection = {MediaStore.Images.Media.DATA};
        Cursor cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
        if (cursor != null) {
            int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
            cursor.moveToFirst();
            filePath = cursor.getString(column_index);
            cursor.close();
        }
    } catch (IllegalArgumentException e) {
        //LogUtils.error(e);
    }
    return filePath;
}
 
Example 2
Project: COB   File: CameraLauncher.java   Source Code and License Vote up 6 votes
/**
 * Used to find out if we are in a situation where the Camera Intent adds to images
 * to the content store. If we are using a FILE_URI and the number of images in the DB
 * increases by 2 we have a duplicate, when using a DATA_URL the number is 1.
 *
 * @param type FILE_URI or DATA_URL
 */
private void checkForDuplicateImage(int type) {
    int diff = 1;
    Uri contentStore = whichContentStore();
    Cursor cursor = queryImgDB(contentStore);
    int currentNumOfImages = cursor.getCount();

    if (type == FILE_URI && this.saveToPhotoAlbum) {
        diff = 2;
    }

    // delete the duplicate file if the difference is 2 for file URI or 1 for Data URL
    if ((currentNumOfImages - numPics) == diff) {
        cursor.moveToLast();
        int id = Integer.valueOf(cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media._ID)));
        if (diff == 2) {
            id--;
        }
        Uri uri = Uri.parse(contentStore + "/" + id);
        this.cordova.getActivity().getContentResolver().delete(uri, null, null);
        cursor.close();
    }
}
 
Example 3
Project: letv   File: DownloadManager.java   Source Code and License Vote up 6 votes
public static DownloadVideo getDownloadVideoData(String vid) {
    Cursor cursor = null;
    DownloadVideo downloadVideo = null;
    try {
        Query query = new Query(sConext.getContentResolver());
        query.setUri(DOWNLOAD_VIDEO_URI);
        query.setSelection("vid = " + vid);
        cursor = query(query);
        cursor.moveToFirst();
        downloadVideo = DownloadVideoTable.cursorToDownloadVideo(cursor);
        if (!(cursor == null || cursor.isClosed())) {
            cursor.close();
        }
    } catch (Exception e) {
        e.printStackTrace();
        if (!(cursor == null || cursor.isClosed())) {
            cursor.close();
        }
    } catch (Throwable th) {
        if (!(cursor == null || cursor.isClosed())) {
            cursor.close();
        }
    }
    return downloadVideo;
}
 
Example 4
Project: letv   File: DownloadDBDao.java   Source Code and License Vote up 6 votes
public DownloadVideo getDownloadVideoByVid(long vid) {
    Cursor cursor = null;
    try {
        cursor = queryByID(DownloadVideoTable.CONTENT_URI, null, "vid = " + vid, null, null);
        if (cursor != null) {
            cursor.moveToFirst();
            DownloadVideo cursorToDownloadVideo = DownloadVideoTable.cursorToDownloadVideo(cursor);
            return cursorToDownloadVideo;
        }
        if (!(cursor == null || cursor.isClosed())) {
            cursor.close();
        }
        return null;
    } finally {
        if (!(cursor == null || cursor.isClosed())) {
            cursor.close();
        }
    }
}
 
Example 5
Project: starcraft-2-build-player   File: DbAdapter.java   Source Code and License Vote up 6 votes
/**
 * Returns a build's ID given its unique name. Returns -1
 * if no build with the given name exists in DB.
 *
 * @param uniqueName
 * @return Build table row ID
 */
public long getBuildID(String uniqueName) {
    Cursor cursor = null;

    try {
        cursor = mDb.query(TABLE_BUILD_ORDER,
                new String[]{KEY_BUILD_ORDER_ID},
                KEY_NAME + " = ?",
                new String[]{uniqueName}, null, null, null);
        if (cursor.getCount() == 0)
            return -1;

        cursor.moveToFirst();
        return cursor.getLong(0);
    } finally {
        if (cursor != null)
            cursor.close();
    }
}
 
Example 6
Project: orgzly-android   File: LocalDbRepoClient.java   Source Code and License Vote up 6 votes
private static VersionedRook get(Context context, Uri uri) {
    Cursor cursor = context.getContentResolver().query(
            ProviderContract.LocalDbRepo.ContentUri.dbRepos(),
            null,
            ProviderContract.LocalDbRepo.Param.URL + " = ?",
            new String[] { uri.toString() },
            null);

    try {
        if (cursor.moveToFirst()) {
            return fromCursor(cursor);
        }
    } finally {
        cursor.close();
    }

    return null;
}
 
Example 7
Project: Cash   File: tblVendaRecebimentos.java   Source Code and License Vote up 5 votes
public List<String> getListAno() {

        List<String> mList = new ArrayList<>();

        Cursor cursor;
        cursor = Funcoes.mDataBase.query(mTable, new String[]{"ano"}, null, null, "ano", null, null);
        while (cursor.moveToNext()) {
            mList.add(cursor.getString(cursor.getColumnIndex("ano")));
        }
        cursor.close();

        return mList;
    }
 
Example 8
Project: IdeaTrackerPlus   File: DatabaseHelper.java   Source Code and License Vote up 5 votes
/**
 * Count the ideas in the different tabs for the current project (table)
 *
 * @param tabNumber 0 for NOW+LATER, 1 for Now/IDEAS, 2 for LATER, 3 for DONE
 * @return
 */
public int getIdeasCount(int tabNumber) {

    int count = 0;
    Cursor cursor = null;
    try {
        switch (tabNumber) {
            case 0: //NOW+LATER
                cursor = getReadableDatabase().rawQuery("select count(*) from " + DataEntry.TABLE_NAME + " where done=0 and temp=0", null);
                break;

            case 1: //NOW/IDEAS
                cursor = getReadableDatabase().rawQuery("select count(*) from " + DataEntry.TABLE_NAME + " where done=0 and temp=0 and later=0", null);
                break;

            case 2: //LATER
                cursor = getReadableDatabase().rawQuery("select count(*) from " + DataEntry.TABLE_NAME + " where done=0 and temp=0 and later=1", null);
                break;

            case 3: //DONE
                cursor = getReadableDatabase().rawQuery("select count(*) from " + DataEntry.TABLE_NAME + " where done=1 and temp=0", null);
                break;
        }

        cursor.moveToFirst();
        count = cursor.getInt(0);
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }

    return count;
}
 
Example 9
Project: TestChat   File: ChatDB.java   Source Code and License Vote up 5 votes
/**
 * 获取所有的群结构表
 *
 * @return 结果集
 */
public List<GroupTableMessage> getAllGroupMessage() {
        List<GroupTableMessage> list = null;
        if (mDatabase.isOpen()) {
                Cursor cursor = mDatabase.rawQuery("select * from " + GROUP_TABLE, null);
                if (cursor != null) {
                        list = new ArrayList<>();
                        GroupTableMessage groupTableMessage;
                        while (cursor.moveToNext()) {
                                groupTableMessage = new GroupTableMessage();
                                groupTableMessage.setGroupId(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_ID)));
                                groupTableMessage.setObjectId(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_OBJECT_ID)));
                                groupTableMessage.setCreatorId(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_CREATOR_ID)));
                                groupTableMessage.setCreatedTime(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_CREATE_TIME)));
                                groupTableMessage.setGroupDescription(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_DESCRIPTION)));
                                groupTableMessage.setGroupAvatar(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_AVATAR)));
                                groupTableMessage.setGroupName(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_NAME)));
                                groupTableMessage.setGroupNick(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_NICK)));
                                groupTableMessage.setToId(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_TO_ID)));
                                groupTableMessage.setSendStatus(cursor.getInt(cursor.getColumnIndexOrThrow(GROUP_SEND_STATUS)));
                                groupTableMessage.setReadStatus(cursor.getInt(cursor.getColumnIndexOrThrow(GROUP_READ_STATUS)));
                                groupTableMessage.setGroupNumber(CommonUtils.string2list(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_NUMBER))));
                                groupTableMessage.setNotification(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_NOTIFICATION)));
                                list.add(groupTableMessage);
                        }
                        if (!cursor.isClosed()) {
                                cursor.close();
                        }
                }
        }
        return list;
}
 
Example 10
Project: iosched-reader   File: ExploreSessionsActivity.java   Source Code and License Vote up 5 votes
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    switch (loader.getId()) {
        case TAG_METADATA_TOKEN:
            mTagMetadata = new TagMetadata(cursor);
            onTagMetadataLoaded();
            break;
        default:
            cursor.close();
    }
}
 
Example 11
Project: GitHub   File: BookmarksPresenter.java   Source Code and License Vote up 5 votes
@Override
public void checkForFreshData() {

    // every first one of the 3 lists is with header
    // add them in advance

    types.add(TYPE_ZHIHU_WITH_HEADER);
    Cursor cursor = db.rawQuery("select * from Zhihu where bookmark = ?", new String[]{"1"});
    if (cursor.moveToFirst()) {
        do {
            ZhihuDailyNews.Question question = gson.fromJson(cursor.getString(cursor.getColumnIndex("zhihu_news")), ZhihuDailyNews.Question.class);
            zhihuList.add(question);
            types.add(TYPE_ZHIHU_NORMAL);
        } while (cursor.moveToNext());
    }

    types.add(TYPE_GUOKR_WITH_HEADER);
    cursor = db.rawQuery("select * from Guokr where bookmark = ?", new String[]{"1"});
    if (cursor.moveToFirst()) {
        do {
            GuokrHandpickNews.result result = gson.fromJson(cursor.getString(cursor.getColumnIndex("guokr_news")), GuokrHandpickNews.result.class);
            guokrList.add(result);
            types.add(TYPE_GUOKR_NORMAL);
        } while (cursor.moveToNext());
    }

    types.add(TYPE_DOUBAN_WITH_HEADER);
    cursor = db.rawQuery("select * from Douban where bookmark = ?", new String[]{"1"});
    if (cursor.moveToFirst()) {
        do {
            DoubanMomentNews.posts post = gson.fromJson(cursor.getString(cursor.getColumnIndex("douban_news")), DoubanMomentNews.posts.class);
            doubanList.add(post);
            types.add(TYPE_DOUBAN_NORMAL);
        } while (cursor.moveToNext());
    }

    cursor.close();

}
 
Example 12
Project: boohee_v5.6   File: NoticeDao.java   Source Code and License Vote up 5 votes
public ArrayList<Notice> getNotices() {
    ArrayList<Notice> alarms = new ArrayList();
    Cursor cursor = this.db.query(TABLE_NAME, null, null, null, null, null, "created_at DESC");
    if (cursor != null) {
        while (cursor.moveToNext()) {
            alarms.add(selectWithCursor(cursor));
        }
        cursor.close();
    }
    return alarms;
}
 
Example 13
Project: treehugger   File: DBhandler.java   Source Code and License Vote up 5 votes
public static List<Tree> getRegionTreeList(Context context, Projection projectionRigion) {

        if (dbstatic == null) {
            TreeDBHelper dbHelper = new TreeDBHelper(context);
            dbstatic = dbHelper.getReadableDatabase();
        }

        String[] projection = new String[]{TreeDBContract.TreeEntry.COLUMN_NAME_TRAE_ART,
                TreeDBContract.TreeEntry.COLUMN_NAME_DANSK_NAVN,
                COLUMN_NAME_COORDINATE_LAT,
                TreeDBContract.TreeEntry.COLUMN_NAME_COORDINATE_LON};

        LatLngBounds bounds = projectionRigion.getVisibleRegion().latLngBounds;

        String selection = COLUMN_NAME_COORDINATE_LAT +
                " Between " + bounds.southwest.latitude +
                " And " + bounds.northeast.latitude +
                " And " + COLUMN_NAME_COORDINATE_LON +
                " Between " + bounds.southwest.longitude +
                " And " + bounds.northeast.longitude +
                " LIMIT 2000";

        Cursor cursor = dbstatic.query(TreeDBContract.TreeEntry.TABLE_NAME, projection, selection, null, null, null, null);
        List<Tree> trees = new ArrayList<>(cursor.getCount());
        while (cursor.moveToNext()) {
            Tree tree = new Tree(cursor.getString(cursor.getColumnIndex(TreeDBContract.TreeEntry.COLUMN_NAME_TRAE_ART)),
                    cursor.getString(cursor.getColumnIndex(TreeDBContract.TreeEntry.COLUMN_NAME_DANSK_NAVN)),
                    cursor.getDouble(cursor.getColumnIndex(COLUMN_NAME_COORDINATE_LAT)),
                    cursor.getDouble(cursor.getColumnIndex(TreeDBContract.TreeEntry.COLUMN_NAME_COORDINATE_LON)));
            trees.add(tree);
        }
        cursor.close();

        return trees;
    }
 
Example 14
Project: sekai   File: UserRepo.java   Source Code and License Vote up 5 votes
public User getUserById(long Id){
    SQLiteDatabase db = dbHandler.getReadableDatabase();
    String selectQuery =  "SELECT " +
            User.KEY_ID + "," +
            User.KEY_LAST_NAME + "," +
            User.KEY_FIRST_NAME + "," +
            User.KEY_EMAIL + "," +
            User.KEY_COUNTRY +
            " FROM " + User.TABLE
            + " WHERE " +
            User.KEY_ID + "=?";// It's a good practice to use parameter ?, instead of concatenate string

    User user = new User();

    Cursor cursor = db.rawQuery(selectQuery, new String[] { String.valueOf(Id) } );

    if (cursor.moveToFirst()) {
        do {
            user.id =cursor.getInt(cursor.getColumnIndex(User.KEY_ID));
            user.last_name =cursor.getString(cursor.getColumnIndex(User.KEY_LAST_NAME));
            user.first_name =cursor.getString(cursor.getColumnIndex(User.KEY_FIRST_NAME));
            user.email =cursor.getString(cursor.getColumnIndex(User.KEY_EMAIL));
            user.home_country = cursor.getInt(cursor.getColumnIndex(User.KEY_COUNTRY));
        } while (cursor.moveToNext());
    }

    cursor.close();
    db.close();
    return user;
}
 
Example 15
Project: TestChat   File: ChatDB.java   Source Code and License Vote up 5 votes
public User getContact(String uid) {
        User user = null;
        if (mDatabase.isOpen()) {
                Cursor cursor = mDatabase.query(CONTACTS_TABLE_NAME, null, CONTACTS_UID + " =?", new String[]{uid}, null, null, null);
                if (cursor != null && cursor.moveToFirst()) {
                        user = new User();
                        user.setUsername(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_NAME)));
                        user.setObjectId(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_UID)));
                        user.setAvatar(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_AVATAR)));
                        user.setSex(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_SEX)).equals("男"));
                        user.setNick(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_NICK)));
                        user.setSortedKey(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_SORT_KEY)));
                        user.setInstallId(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_INSTALLATION_ID)));
                        user.setSignature(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_SIGNATURE)));
                        user.setMobilePhoneNumber(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_PHONE)));
                        user.setEmail(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_EMAIL)));
                        user.setBirthDay(cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_BIRTHDAY)));
                        String location = cursor.getString(cursor.getColumnIndexOrThrow(CONTACTS_LOCATION));
                        if (location != null && !location.equals("")) {
                                String[] loglat = location.split("&");
                                user.setLocation(new BmobGeoPoint(Double.parseDouble(loglat[0]), Double.parseDouble(loglat[1])));
                        }
                }
                if (cursor != null && !cursor.isClosed()) {
                        cursor.close();
                }
        }
        return user;
}
 
Example 16
Project: filepicker   File: OtherFilePickerModel.java   Source Code and License Vote up 5 votes
@Override
public Observable<List<Folder>> getAllFiles() {
    Cursor cursor = mContext.getContentResolver().query(MediaStore.Files.getContentUri("external"), FILE_PROJECTION,
            null, null, DATE_ADDED + " DESC");
    List<Folder> folders = onLoadOtherFile(cursor);
    cursor.close();
    return Observable.just(folders);
}
 
Example 17
Project: PRDownloader   File: AppDbHelper.java   Source Code and License Vote up 5 votes
@Override
public DownloadModel find(int id) {
    Cursor cursor = null;
    DownloadModel model = null;
    try {
        cursor = db.rawQuery("SELECT * FROM " + TABLE_NAME + " WHERE " +
                DownloadModel.ID + " = " + id, null);
        if (cursor != null && cursor.moveToFirst()) {
            model = new DownloadModel();
            model.setId(id);
            model.setUrl(cursor.getString(cursor.getColumnIndex(DownloadModel.URL)));
            model.setETag(cursor.getString(cursor.getColumnIndex(DownloadModel.ETAG)));
            model.setDirPath(cursor.getString(cursor.getColumnIndex(DownloadModel.DIR_PATH)));
            model.setFileName(cursor.getString(cursor.getColumnIndex(DownloadModel.FILE_NAME)));
            model.setTotalBytes(cursor.getLong(cursor.getColumnIndex(DownloadModel.TOTAL_BYTES)));
            model.setDownloadedBytes(cursor.getLong(cursor.getColumnIndex(DownloadModel.DOWNLOADED_BYTES)));
            model.setLastModifiedAt(cursor.getLong(cursor.getColumnIndex(DownloadModel.LAST_MODIFIED_AT)));
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
    return model;
}
 
Example 18
Project: CodeWatch   File: TestDb.java   Source Code and License Vote up 4 votes
public void testCreateDb() throws Throwable {

        mContext.deleteDatabase(LeaderDbHelper.DATABASE_NAME);
        SQLiteDatabase db = new LeaderDbHelper(this.mContext).getWritableDatabase();
        assertEquals(true, db.isOpen());

        Cursor c = db.rawQuery("SELECT name FROM sqlite_master WHERE type='table'", null);

        assertTrue("Error: This means that the database has not been created correctly", c.moveToFirst());

        c.moveToNext(); //to skip android_metadata table

        assertTrue("Error: Your database was created without leader table", c.getString(0).equals(TABLE_NAME));

        // now, do our tables contain the correct columns?
        c = db.rawQuery("PRAGMA table_info(" + TABLE_NAME + ")", null);

        assertTrue("Error: This means that we were unable to query the database for table information.",
                c.moveToFirst());

        // Build a HashSet of all of the column names we want to look for
        final HashSet<String> leaderColumnHashSet = new HashSet<>();
        leaderColumnHashSet.add(LeaderContract.LeaderEntry._ID);
        leaderColumnHashSet.add(LeaderContract.LeaderEntry.COLUMN_DAILY_AVERAGE);
        leaderColumnHashSet.add(LeaderContract.LeaderEntry.COLUMN_EMAIL);
        leaderColumnHashSet.add(LeaderContract.LeaderEntry.COLUMN_LANGUAGE_STATS);
        leaderColumnHashSet.add(LeaderContract.LeaderEntry.COLUMN_PHOTO);
        leaderColumnHashSet.add(LeaderContract.LeaderEntry.COLUMN_TOTAL_SECONDS);
        leaderColumnHashSet.add(LeaderContract.LeaderEntry.COLUMN_DISPLAY_NAME);
        leaderColumnHashSet.add(LeaderContract.LeaderEntry.COLUMN_USER_ID);
        leaderColumnHashSet.add(LeaderContract.LeaderEntry.COLUMN_USER_NAME);
        leaderColumnHashSet.add(LeaderContract.LeaderEntry.COLUMN_RANK);
        leaderColumnHashSet.add(LeaderContract.LeaderEntry.COLUMN_WEBSITE);
        leaderColumnHashSet.add(LeaderContract.LeaderEntry.COLUMN_LOCATION);

        int columnNameIndex = c.getColumnIndex("name");
        do {
            String columnName = c.getString(columnNameIndex);
            leaderColumnHashSet.remove(columnName);
        } while (c.moveToNext());

        assertTrue("Error: The database doesn't contain all of the required leader entry columns",
                leaderColumnHashSet.isEmpty());
        c.close();
        db.close();
    }
 
Example 19
Project: q-mail   File: AttachmentInfoLoader.java   Source Code and License Vote up 4 votes
@Override
public Attachment loadInBackground() {
    Uri uri = sourceAttachment.uri;
    String contentType = sourceAttachment.contentType;

    long size = -1;
    String name = null;

    ContentResolver contentResolver = getContext().getContentResolver();

    Cursor metadataCursor = contentResolver.query(
            uri,
            new String[] { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE },
            null,
            null,
            null);

    if (metadataCursor != null) {
        try {
            if (metadataCursor.moveToFirst()) {
                name = metadataCursor.getString(0);
                size = metadataCursor.getInt(1);
            }
        } finally {
            metadataCursor.close();
        }
    }

    if (name == null) {
        name = uri.getLastPathSegment();
    }

    String usableContentType = contentResolver.getType(uri);
    if (usableContentType == null && contentType != null && contentType.indexOf('*') != -1) {
        usableContentType = contentType;
    }

    if (usableContentType == null) {
        usableContentType = MimeUtility.getMimeTypeByExtension(name);
    }

    if (size <= 0) {
        String uriString = uri.toString();
        if (uriString.startsWith("file://")) {
            File f = new File(uriString.substring("file://".length()));
            size = f.length();
        } else {
            Timber.v("Not a file: %s", uriString);
        }
    } else {
        Timber.v("old attachment.size: %d", size);
    }
    Timber.v("new attachment.size: %d", size);

    cachedResultAttachment = sourceAttachment.deriveWithMetadataLoaded(usableContentType, name, size);
    return cachedResultAttachment;
}
 
Example 20
Project: Taxi-Datalogger   File: CloudPublisherService.java   Source Code and License Vote up 4 votes
@WorkerThread
void processCollectedSensorData() throws JSONException {
    if (mPublisher == null || !mPublisher.isReady()) {
        return;
    }

    // Query the data we wish to push to the cloud
    long lastSyndId = DatalogDbHelper.getLastSyncId(this);
    Cursor cursor = mDatabase.query(DatalogDbHelper.TABLE_NAME,
            null,
            DatalogDbHelper.DatalogEntry._ID + " > " + lastSyndId,
            null,
            null,
            null,
            BaseColumns._ID + " ASC");
    Log.i(TAG, "publishing " + cursor.getCount() + " log entries");

    final int columnCount = cursor.getColumnCount();
    for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
        JSONObject entryObject = new JSONObject();
        // Add the device ID to the JSON record.
        //
        // FIXME: There should be a way to get Google Cloud IOT to do this on its
        // end, so I don't need to trust the IDs.
        entryObject.put("deviceId", mDeviceId);
        long id = 0;
        for (int i = 0; i < columnCount; i++) {
            String columnName = cursor.getColumnName(i);
            if (columnName != null) {
                // Note the most recent ID we've transmitted, but don't include
                // the ID column in the JSON message
                if (columnName.equals(BaseColumns._ID)) {
                    id = cursor.getLong(i);
                    continue;
                }
                if (cursor.getType(i) == Cursor.FIELD_TYPE_FLOAT) {
                    entryObject.put(columnName, cursor.getDouble(i));
                } else {
                    entryObject.put(columnName, cursor.getString(i));
                }
            }
        }
        // Push message to the cloud
        mPublisher.publish(entryObject.toString());
        Log.d(TAG, "Sent entry: " + (cursor.getPosition()+1) + "/" +
                cursor.getCount());
        if (id > lastSyndId)
            DatalogDbHelper.setLastSyncId(this, id);
    }
    cursor.close();
}