Read data of the last database entry and returns the data as a cursor - Android Database

Android examples for Database:Cursor Get

Description

Read data of the last database entry and returns the data as a cursor

Demo Code


//package com.java2s;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class Main {
    /** Name of the table */
    private static final String TABLE_NAME = "s";


    public static Cursor getLastRow(SQLiteDatabase db) {
        return db.rawQuery("select * from " + TABLE_NAME
                + " order by id desc LIMIT 1", null);
    }//  w w w  .  j a  v a2 s.  c  o  m
}

Related Tutorials