当前位置: 首页>>代码示例>>Java>>正文


Java Cursor.moveToLast方法代码示例

本文整理汇总了Java中android.database.Cursor.moveToLast方法的典型用法代码示例。如果您正苦于以下问题:Java Cursor.moveToLast方法的具体用法?Java Cursor.moveToLast怎么用?Java Cursor.moveToLast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.database.Cursor的用法示例。


在下文中一共展示了Cursor.moveToLast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkForDuplicateImage

import android.database.Cursor; //导入方法依赖的package包/类
/**
 * 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();
    }
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:30,代码来源:CameraLauncher.java

示例2: getAllTasks

import android.database.Cursor; //导入方法依赖的package包/类
public List<TasksManagerModel> getAllTasks() {
    final Cursor c = db.rawQuery("SELECT * FROM " + TABLE_NAME, null);

    final List<TasksManagerModel> list = new ArrayList<>();
    try {
        if (!c.moveToLast()) {
            return list;
        }

        do {
            TasksManagerModel model = new TasksManagerModel();
            model.setId(c.getInt(c.getColumnIndex(TasksManagerModel.ID)));
            model.setName(c.getString(c.getColumnIndex(TasksManagerModel.NAME)));
            model.setUrl(c.getString(c.getColumnIndex(TasksManagerModel.URL)));
            model.setPath(c.getString(c.getColumnIndex(TasksManagerModel.PATH)));
            list.add(model);
        } while (c.moveToPrevious());
    } finally {
        if (c != null) {
            c.close();
        }
    }

    return list;
}
 
开发者ID:yannanzheng,项目名称:FileDownloader-master,代码行数:26,代码来源:TasksManagerDBController.java

示例3: getPageHezb

import android.database.Cursor; //导入方法依赖的package包/类
public int getPageHezb(int pageNumber) {
    int hezbNumber = 0;
    try {
        SQLiteDatabase db = openDB(MAIN_DATABASE);
        String sql = "select hezb from aya where page = " + pageNumber + " ;";
        Cursor cursor = db.rawQuery(sql, null);

        if(cursor.moveToLast()){
            hezbNumber = cursor.getInt(0);
        }
        cursor.close();
        closeDB(db);
        return hezbNumber;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return hezbNumber;
}
 
开发者ID:fekracomputers,项目名称:QuranAndroid,代码行数:19,代码来源:DatabaseAccess.java

示例4: onChange

import android.database.Cursor; //导入方法依赖的package包/类
@Override public void onChange(boolean selfChange, Uri uri) {
  ArrayList<String> phoneNumber = new ArrayList<>();
  super.onChange(selfChange, uri);
  Log.d(LOG_TAG, "Contact has changed");

  Cursor cursor = getReactApplicationContext().getContentResolver()
      .query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);

  if (!cursor.moveToFirst()) return;

  cursor.moveToLast();
  String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
  String phone =
      cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
  Log.d(LOG_TAG, "id = " + name + "\n name = " + name);
  phoneNumber.add(phone);
  synchronizePhoneNumber(phoneNumber);
}
 
开发者ID:humaniq,项目名称:react-native-android-library-humaniq-api,代码行数:19,代码来源:ContactsModule.java

示例5: getLastMessage

import android.database.Cursor; //导入方法依赖的package包/类
public Message getLastMessage(int roomID) throws Exception {
    String roomIDString = getRoomIdString(roomID);
    String query = "SELECT * FROM "+roomIDString+" ORDER BY "+ROOM_TIMESTAMP+" ASC";
    SQLiteDatabase db = getWritableDatabase();

    Cursor c = db.rawQuery(query, null);
    c.moveToLast();
    int messageID = c.getInt(c.getColumnIndex(ROOM_MESSAGEID));
    String name = c.getString(c.getColumnIndex(ROOM_SENDER));
    String text = c.getString(c.getColumnIndex(ROOM_TEXT));
    long timestamp = c.getLong(c.getColumnIndex(ROOM_TIMESTAMP));

    Message message = new Message(messageID, roomID, name, text, timestamp);
    c.close();
    db.close();
    return message;
}
 
开发者ID:Thizizmyname,项目名称:MyPlace,代码行数:18,代码来源:RoomDbHelper.java

示例6: getLastAlarm

import android.database.Cursor; //导入方法依赖的package包/类
public AlarmResponse getLastAlarm(int versionCode) {
    String whereClause = "targetVersion = " + versionCode;
    Cursor cursor = null;
    try {
        cursor = this.openHelper.getReadableDatabase().query(DBConstants.TABLE_ALARM, null, whereClause, null, null, null, DBConstants.ID);
        if (!cursor.moveToLast()) {
            return null;
        }
        AlarmResponse alarmFromCursor = getAlarmFromCursor(cursor);
        if (cursor == null) {
            return alarmFromCursor;
        }
        cursor.close();
        return alarmFromCursor;
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:21,代码来源:DataBaseAccess.java

示例7: getLastRoad

import android.database.Cursor; //导入方法依赖的package包/类
public RoadModel getLastRoad(long folderId) {
    Cursor c = getAllRoadByFolderIdCursor(folderId);
    RoadModel road = null;
    try {
        if (c != null) {
            if (c.getCount() > 0) {
                c.moveToLast();
                road = cursorToRoad(c);
            }
            c.close();
        }
    } catch (Exception e) {
        Log.e(TAG, e != null && e.getMessage() != null ? e.getMessage() : "");
    }
    return road;
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:17,代码来源:RoadDAO.java

示例8: getDisableApps

import android.database.Cursor; //导入方法依赖的package包/类
/**
 * 获取主页停用列表apps
 *
 * @param tableName
 * @return
 */
public List<AppInfo> getDisableApps(String tableName) {
    final Cursor cursor = mSQLiteDatabase.rawQuery("SELECT * FROM " + tableName, null);

    final List<AppInfo> list = new ArrayList<>();
    try {
        if (!cursor.moveToLast()) {
            return list;
        }
        do {
            AppInfo appInfo = new AppInfo();
            appInfo.setAppPackageName(cursor.getString(cursor.getColumnIndex(AppInfo.APP_PACKAGE_NAME)));
            appInfo.setAppName(cursor.getString(cursor.getColumnIndex(AppInfo.APP_NAME)));
            MyLogger.e(cursor.getString(cursor.getColumnIndex(AppInfo.APP_NAME)));
            appInfo.setAppIcon(CommonUtil.getImage(cursor.getBlob(cursor.getColumnIndex(AppInfo.APP_ICON))));
            appInfo.setEnable(cursor.getInt(cursor.getColumnIndex(AppInfo.IS_ENABLE)));
            appInfo.setSystemApp(cursor.getInt(cursor.getColumnIndex(AppInfo.IS_SYSTEM_APP)));
            list.add(appInfo);
        } while (cursor.moveToPrevious());
    } finally {
        if (cursor != null && !cursor.isClosed()) {
            cursor.close();
        }
    }

    return list;
}
 
开发者ID:XYScience,项目名称:StopApp,代码行数:33,代码来源:AppInfoDBController.java

示例9: getUrlDataFromDB

import android.database.Cursor; //导入方法依赖的package包/类
private String getUrlDataFromDB() {
        Cursor cursor = mSQLiteDataBase.rawQuery("SELECT url_data FROM my_url_data", null);
        cursor.moveToLast();
        String a = cursor.getString(cursor.getColumnIndex("url_data"));
//        String s = cursor.getString(2);
        return a;
    }
 
开发者ID:Evan-Galvin,项目名称:FreeStreams-TVLauncher,代码行数:8,代码来源:MainActivity.java

示例10: findLastValue

import android.database.Cursor; //导入方法依赖的package包/类
protected static int findLastValue(DBHandler db, String tableName){
    int foundValue;
    String selectQuery = "SELECT  * FROM " + tableName;
    SQLiteDatabase db1 = db.getReadableDatabase();
    Cursor cursor = db1.rawQuery(selectQuery, null);
    cursor.moveToLast();
    foundValue = Integer.parseInt(cursor.getString(1));
    cursor.close();
    return foundValue;
}
 
开发者ID:Durian-Inc,项目名称:SwolyV2,代码行数:11,代码来源:MaxesAdapter.java

示例11: gewaehlteFaecherAnTag

import android.database.Cursor; //导入方法依赖的package包/类
public Fach[] gewaehlteFaecherAnTag(int tag) {
    String table = TABLE_FAECHER + ", " + TABLE_GEWAEHLT + ", " + TABLE_STUNDEN;
    String[] columns = {TABLE_FAECHER + "." + FACH_ID,
            FACH_KURZEL,
            FACH_NAME,
            FACH_ART,
            FACH_LEHRER,
            FACH_KLASSE,
            STUNDE_RAUM,
            STUNDEN_STUNDE,
            GEWAEHLT_SCHRIFTLICH,
            STUNDE_NOTIZ};
    String selection = TABLE_FAECHER + "." + FACH_ID + " = " + TABLE_STUNDEN + "." + FACH_ID + " AND " + TABLE_FAECHER + "." + FACH_ID + " = " + TABLE_GEWAEHLT + "." + FACH_ID + " AND " + TABLE_STUNDEN + "." + STUNDEN_TAG + " = " + tag;
    Cursor cursor    = database.query(table, columns, selection, null, null, null, STUNDEN_STUNDE);
    Fach[] faecher   = new Fach[0];
    if (cursor.getCount() > 0) {
        cursor.moveToLast();
        faecher = new Fach[cursor.getInt(7)];
        for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
            faecher[cursor.getInt(7) - 1] = new Fach(cursor.getInt(0), cursor.getString(1), cursor.getString(2) + (cursor.getString(3).equals("LK") ? " LK" : ""), cursor.getString(4), cursor.getString(5), cursor.getString(6), tag, cursor.getInt(7));
            faecher[cursor.getInt(7) - 1].setzeNotiz(cursor.getString(9));
            faecher[cursor.getInt(7) - 1].setzeSchriftlich(cursor.getInt(8) == 1);
        }
        for (int i = 0; i < faecher.length; i++) {
            if (faecher[i] == null)
                faecher[i] = new Fach(0, "", "", "", "", "", tag, i + 1);
        }
    }
    cursor.close();
    return faecher;
}
 
开发者ID:LCA311,项目名称:leoapp-sources,代码行数:32,代码来源:SQLiteConnectorStundenplan.java

示例12: getLastItemId

import android.database.Cursor; //导入方法依赖的package包/类
private int getLastItemId(Integer databaseKey) {
    open();
    String sql = "SELECT " + SearchHistoryDatabase.SEARCH_HISTORY_COLUMN_ID + " FROM " + SearchHistoryDatabase.SEARCH_HISTORY_TABLE;
    if (databaseKey != null)
        sql += " WHERE " + SearchHistoryDatabase.SEARCH_HISTORY_KEY + " = " + databaseKey;
    Cursor res = db.rawQuery(sql, null);
    res.moveToLast();
    int count = res.getInt(0);
    close();
    res.close();
    return count;
}
 
开发者ID:sega4revenge,项目名称:Sega,代码行数:13,代码来源:SearchHistoryTable.java

示例13: aggregateEvents

import android.database.Cursor; //导入方法依赖的package包/类
/**
 * Iterates sqlite cursor and builds complete GameHarvest objects
 *
 * @param cursor           sqlite cursor
 * @param getDeletedImages
 * @return List of GameHarvest objects
 */
private List<GameHarvest> aggregateEvents(Cursor cursor, boolean getDeletedImages) {
    cursor.moveToFirst();
    List<LogImage> logImages = new ArrayList<LogImage>();
    boolean first = true;
    int lastId = 0;
    List<GameHarvest> logEvents = new ArrayList<GameHarvest>();
    while (!cursor.isAfterLast()) {
        int eventId = cursor.getInt(cursor.getColumnIndex(DiaryHelper.COLUMN_LOCALID));
        if (!first && eventId != lastId) {
            cursor.moveToPrevious();
            logEvents.add(createEvent(cursor, logImages));
            logImages = new ArrayList<LogImage>();
            cursor.moveToNext();
        }
        LogImage image = logImageFromCursor(cursor, getDeletedImages);
        if (image != null)
            logImages.add(image);
        lastId = eventId;
        cursor.moveToNext();
        first = false;
    }
    if (cursor.getCount() > 0) {
        cursor.moveToLast();
        logEvents.add(createEvent(cursor, logImages));
    }
    return logEvents;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-android,代码行数:35,代码来源:DiaryDataSource.java

示例14: getMessages

import android.database.Cursor; //导入方法依赖的package包/类
private List<HashMap<String,String>> getMessages(String where, String[] whereArgs, int limitStart, int limitEnd){
    Uri uri = Uri.parse("content://sms");

    Cursor c = mContext.getContentResolver().query(uri,
            null,
            where,
            whereArgs,
            "date desc LIMIT "+String.valueOf(limitStart)+", "+String.valueOf(limitEnd)
    );
    List<HashMap<String,String>> ret = new ArrayList<HashMap<String, String>>();
    if (c.getCount() > 0){
        c.moveToLast();
        for (int i = 0; i < c.getCount(); i++) {
            String msgId = c.getString(c.getColumnIndex("_id"));
            String address = c.getString(c.getColumnIndex("address")); // phone #
            String date = c.getString(c.getColumnIndex("date"));
            String body = c.getString(c.getColumnIndex("body"));
            //String seen = c.getString(c.getColumnIndex("read"));
            String type = c.getString(c.getColumnIndex("type"));
            int thread = c.getInt(c.getColumnIndexOrThrow("thread_id"));

            ContactsUtil mContacts = new ContactsUtil(mContext);
            String contactId = mContacts.getContactId(address);

            String name = address;
            if (!(contactId == null)) {
                HashMap<String, String> contact = mContacts.getContactById(Integer.parseInt(contactId));
                name = contact.get("name");
            }

            HashMap<String,String> currMsg = new HashMap<>();
            currMsg.put("address",address);
            currMsg.put("name",name);
            currMsg.put("date",date); //timestamp
            currMsg.put("content",body);
            currMsg.put("contact_id",contactId);
            currMsg.put("type",type);
            currMsg.put("msg_id", msgId);
            currMsg.put("thread_id", String.valueOf(thread));

            ret.add(currMsg);
            c.moveToPrevious();
        }
    }
    return ret;
}
 
开发者ID:strang3quark,项目名称:remotedroid,代码行数:47,代码来源:SMSUtils.java

示例15: onActivityResult

import android.database.Cursor; //导入方法依赖的package包/类
protected void onActivityResult (int requestCode, int resultCode, Intent data) 
{
	super.onActivityResult(requestCode, resultCode, data);
	if (resultCode == Activity.RESULT_OK) {
           ContentResolver reContentResolverol = getContentResolver();
            Uri contactData = data.getData();
            @SuppressWarnings("deprecation")
           Cursor cursor = managedQuery(contactData, null, null, null, null);
            cursor.moveToFirst();
            name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
           String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
           Cursor phone = reContentResolverol.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, 
                    null, 
                    ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = " + contactId, 
                    null, 
                    null);
            while (phone.moveToNext()) {
                number = phone.getString(phone.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));	      
                }
            isfrist=false;
          //add a contact  
            db.open(); 
            long id = db.insertContact(name, number);
    		if(isfrist !=true)
    		{	
    			//get a contact  
    	        db.open();
    	       Cursor a = db.getContact(id);
    	       
    	        if (a.moveToLast()){
     			 Map<String, Object> map = new HashMap<String, Object>();
     	            map.put("contacts_name", name);
     	            map.put("contacts_num", number);
     	            dataList.add(map);
     	            simpleadapter = new SimpleAdapter(this, dataList, R.layout.contact_text, new String[]{"contacts_name","contacts_num"}, 
     		 				new int[]{R.id.contacts_name,R.id.contacts_num});
     	            listView.setAdapter(simpleadapter);  
     	            simpleadapter.notifyDataSetChanged();
    	           // DisplayContact(a);
    	            
    	        }
    	        else 
    	            Toast.makeText(this, "No contact found!", Toast.LENGTH_SHORT).show(); 
    		}
    		db.close(); 
	}
            
 }
 
开发者ID:Edward7Zhang,项目名称:oneKey2Alarm,代码行数:49,代码来源:contacts.java


注:本文中的android.database.Cursor.moveToLast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。