當前位置: 首頁>>代碼示例>>Java>>正文


Java Cursor.moveToNext方法代碼示例

本文整理匯總了Java中android.database.Cursor.moveToNext方法的典型用法代碼示例。如果您正苦於以下問題:Java Cursor.moveToNext方法的具體用法?Java Cursor.moveToNext怎麽用?Java Cursor.moveToNext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.database.Cursor的用法示例。


在下文中一共展示了Cursor.moveToNext方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAlbumArtPicPath

import android.database.Cursor; //導入方法依賴的package包/類
private synchronized String getAlbumArtPicPath(Context context, String albumId) {

        // 小米應用商店檢測crash ,錯誤信息:[31188,0,com.duan.musicoco,13155908,java.lang.IllegalStateException,Unknown URL: content://media/external/audio/albums/null,Parcel.java,1548]
        if (!StringUtils.isReal(albumId)) {
            return null;
        }

        String[] projection = {MediaStore.Audio.Albums.ALBUM_ART};
        String imagePath = null;
        Uri uri = Uri.parse("content://media" + MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI.getPath() + "/" + albumId);

        Cursor cur = context.getContentResolver().query(uri, projection, null, null, null);
        if (cur == null) {
            return null;
        }

        if (cur.getCount() > 0 && cur.getColumnCount() > 0) {
            cur.moveToNext();
            imagePath = cur.getString(0);
        }
        cur.close();


        return imagePath;
    }
 
開發者ID:DuanJiaNing,項目名稱:Musicoco,代碼行數:26,代碼來源:MediaManager.java

示例2: getCalendarIdForName

import android.database.Cursor; //導入方法依賴的package包/類
public String getCalendarIdForName(String calendarName) {
    String selection = "(" + CalendarContract.Calendars.NAME + " = ?)";
    String[] selectionArgs = new String[] {calendarName};
    Cursor cursor = contentResolver.query(CALENDAR_URI, FIELDS, selection, selectionArgs, null);

    try {
        if (cursor.getCount() > 0) {
            while (cursor.moveToNext()) {
                String id = cursor.getString(0);
                return id;
            }
        }
    } catch (AssertionError ex) { /*TODO: log exception and bail*/ }

    return "";
}
 
開發者ID:schul-cloud,項目名稱:schulcloud-mobile-android,代碼行數:17,代碼來源:CalendarContentUtil.java

示例3: getAllUndoneTasks

import android.database.Cursor; //導入方法依賴的package包/類
public ArrayList<DayTask> getAllUndoneTasks(){
    SQLiteDatabase db = this.getReadableDatabase();
    ArrayList<DayTask> tasks = new ArrayList<>();
    String query = "SELECT * FROM " + VARS.TABLE_NAME + " WHERE " + VARS.STATUS + " = 'false'";
    Cursor cursor = db.rawQuery(query, null);
    cursor.moveToFirst();
    while(!cursor.isAfterLast()){
        DayTask dayTask = new DayTask(cursor.getInt(cursor.getColumnIndex(VARS.ID_NAME)), cursor.getString(cursor.getColumnIndex(VARS.STATUS)),
                cursor.getString(cursor.getColumnIndex(VARS.TITLE)), cursor.getString(cursor.getColumnIndex(VARS.DESCRIPTION)),
                cursor.getString(cursor.getColumnIndex(VARS.DATE)), cursor.getString(cursor.getColumnIndex(VARS.TIME)));
        tasks.add(dayTask);
        cursor.moveToNext();
    }
    cursor.close();
    db.close();
    return tasks;
}
 
開發者ID:mehedi-shafi,項目名稱:My-Day,代碼行數:18,代碼來源:DatabaseHandler.java

示例4: getDecks

import android.database.Cursor; //導入方法依賴的package包/類
public ArrayList<Deck> getDecks(int courseID){
    ArrayList<Deck> deckList = new ArrayList<Deck>();
    String selectQuery = "SELECT * FROM " + TABLE_DECK_DETAIL + " WHERE " + COURSE_ID + "=" + courseID;
    SQLiteDatabase db = this.getReadableDatabase();
    Cursor cursor = db.rawQuery(selectQuery, null);

    cursor.moveToFirst();
    System.out.println("DBHandler courseID in getDecks: " + courseID);
    //loop through all rows to return
    while(!cursor.isAfterLast()){
        Deck deck = new Deck(Integer.parseInt(cursor.getString(0)), courseID,
                cursor.getString(2), Integer.parseInt(cursor.getString(3)));
        deck.set_deckId(courseID);
        deckList.add(deck);

        //Log.i(TAG, "HERE WE ARE CourseID: " + courseID);
        cursor.moveToNext();
    }

    Log.i(TAG, "Return All Deck Names");
    db.close();

    return deckList;
}
 
開發者ID:ASU-CodeDevils,項目名稱:FlashCards,代碼行數:25,代碼來源:DBHandler.java

示例5: listarActividadesSistema

import android.database.Cursor; //導入方法依賴的package包/類
public List<ActivityDataTransfer> listarActividadesSistema(){
    List<ActivityDataTransfer> retList = new ArrayList<>();

    String query = "SELECT * FROM " + TABLA_ACTIVIDADES;
    Cursor c = db.rawQuery(query, null);

    while(c.moveToNext()){
        int id = c.getInt(c.getColumnIndex(KEY_ID));
        String actividad = c.getString(c.getColumnIndex(KEY_ACTIVIDAD));
        Date fCreacion = getDateFromSqlite(c.getString(c.getColumnIndex(KEY_FECHACREACION)));
        String url = c.getString(c.getColumnIndex(KEY_URL_IMAGE));

        ActivityDataTransfer activityDataTransfer = new ActivityDataTransfer(id, actividad, fCreacion, url);
        retList.add(activityDataTransfer);
    }

    return retList;
}
 
開發者ID:TfgReconocimientoPulseras,項目名稱:TrainAppTFG,代碼行數:19,代碼來源:DatabaseAdapter.java

示例6: loadInBackground

import android.database.Cursor; //導入方法依賴的package包/類
@Override
public Cursor loadInBackground() {
    Cursor albums = super.loadInBackground();
    MatrixCursor allAlbum = new MatrixCursor(COLUMNS);
    int totalCount = 0;
    String allAlbumCoverPath = "";
    if (albums != null) {
        while (albums.moveToNext()) {
            totalCount += albums.getInt(albums.getColumnIndex(COLUMN_COUNT));
        }
        if (albums.moveToFirst()) {
            allAlbumCoverPath = albums.getString(albums.getColumnIndex(MediaStore.MediaColumns.DATA));
        }
    }
    allAlbum.addRow(new String[]{Album.ALBUM_ID_ALL, Album.ALBUM_ID_ALL, Album.ALBUM_NAME_ALL, allAlbumCoverPath,
            String.valueOf(totalCount)});

    return new MergeCursor(new Cursor[]{allAlbum, albums});
}
 
開發者ID:zhihu,項目名稱:Matisse,代碼行數:20,代碼來源:AlbumLoader.java

示例7: createObjects

import android.database.Cursor; //導入方法依賴的package包/類
private List<T> createObjects(Cursor c) {
	List<T> items = new ArrayList<T>();
	
	while(c.moveToNext()) {
		T object = Model.createObject(mClass, c);
		
		if(object != null) {
			items.add(object);
		}
	}
	
	return items;
}
 
開發者ID:Linguaculturalists,項目名稱:Phoenicia,代碼行數:14,代碼來源:QuerySet.java

示例8: getPlaylistSongList

import android.database.Cursor; //導入方法依賴的package包/類
@NonNull
public static ArrayList<PlaylistSong> getPlaylistSongList(@NonNull final Context context, final int playlistId) {
    ArrayList<PlaylistSong> songs = new ArrayList<>();
    Cursor cursor = makePlaylistSongCursor(context, playlistId);

    if (cursor != null && cursor.moveToFirst()) {
        do {
            songs.add(getPlaylistSongFromCursorImpl(cursor, playlistId));
        } while (cursor.moveToNext());
    }
    if (cursor != null) {
        cursor.close();
    }
    return songs;
}
 
開發者ID:aliumujib,項目名稱:Orin,代碼行數:16,代碼來源:PlaylistSongLoader.java

示例9: query

import android.database.Cursor; //導入方法依賴的package包/類
public SosContacter query(){
    Cursor cursor=db.rawQuery("select * from tb_sos where ischecked=1",null);
    if(cursor.moveToNext()){
        return  new SosContacter(cursor.getInt(cursor.getColumnIndex("_id")),cursor.getString(cursor.getColumnIndex("name")),
                cursor.getString(cursor.getColumnIndex("relation")),cursor.getString(cursor.getColumnIndex("phone")),
                cursor.getString(cursor.getColumnIndex("content")),cursor.getInt(cursor.getColumnIndex("ischecked")));
    }
    return null;
}
 
開發者ID:fergus825,項目名稱:SmartOrnament,代碼行數:10,代碼來源:SosContacterDAO.java

示例10: getGroupMemberLimit

import android.database.Cursor; //導入方法依賴的package包/類
public ArrayList<ContactBean> getGroupMemberLimit(int pageSkip, int maxCount, String table) {

        ArrayList<ContactBean> gbList = new ArrayList<ContactBean>();
        try {
            String selectQuery = "SELECT " + MEMBER_NAME + ", " + MEMBER_PHONE + ", " + MEMBER_SEARCHKEY + ", " + MEMBER_UID + ", " + MEMBER_FLAG + ", " + MEMBER_ORG_NAME + ", "
                    + MEMBER_PH_BOK_NAME + ", " + MEMBER_ISMY_CONTACT + ", " + MEMBER_BLOOD_GROUP + ", " + MEMBER_ADMIN_FLAG + ", " + MEMBER_CREATED_DATE + " FROM " + table + " Order by " + MEMBER_CREATED_DATE + " " + "LIMIT " + pageSkip + ", " + maxCount;

            SQLiteDatabase db = this.getWritableDatabase();
            Cursor cursor = db.rawQuery(selectQuery, null);
            // looping through all rows and adding to list
            if (cursor.moveToFirst()) {
                do {
                    ContactBean contact = new ContactBean();
                    contact.setName(cursor.getString(0));
                    contact.setNumber(cursor.getString(1));
                    contact.setSearchKey(cursor.getString(2));
                    contact.setUID(cursor.getString(3));
                    contact.setRequestFlag(cursor.getString(4));
                    contact.setOrignalName(cursor.getString(5));
                    contact.setMyPhoneBookName(cursor.getString(6));
                    contact.setIsMyContact(cursor.getInt(7));
                    contact.setmBloodGroup(cursor.getString(8));
                    contact.setAdminFlag(cursor.getString(9));
                    contact.setmCreatedDate(cursor.getString(10));
                    gbList.add(contact);
                } while (cursor.moveToNext());
            }
            if (cursor != null)
                cursor.close();
            db.close();
        } catch (Exception e) {
            // TODO: handle exception
            //Log.e("GroupDBErro", "FetchAllDB " + e.getMessage());
            e.printStackTrace();
        }
        return gbList;
    }
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:38,代碼來源:GroupDb.java

示例11: findAllDownloading

import android.database.Cursor; //導入方法依賴的package包/類
@SuppressWarnings("No problem")
@Override
public List<DownloadInfo> findAllDownloading() {
  Cursor cursor = readableDatabase.query(DefaultDownloadHelper.TABLE_NAME_DOWNLOAD_INFO,
      DOWNLOAD_INFO_COLUMNS, "status!=?", new String[]{
          String.valueOf(STATUS_COMPLETED)}, null, null, "createAt desc");

  List<DownloadInfo> downloads = new ArrayList<>();
  Cursor downloadCursor;
  while (cursor.moveToNext()) {
    DownloadInfo downloadInfo = new DownloadInfo();
    downloads.add(downloadInfo);

    inflateDownloadInfo(cursor, downloadInfo);

    //query download thread info
    downloadCursor = readableDatabase.query(DefaultDownloadHelper.TABLE_NAME_DOWNLOAD_THREAD_INFO,
        DOWNLOAD_THREAD_INFO_COLUMNS, "downloadInfoId=?", new String[]{
            String.valueOf(downloadInfo.getId())}, null, null, null);
    List<DownloadThreadInfo> downloadThreads = new ArrayList<>();
    while (downloadCursor.moveToNext()) {
      DownloadThreadInfo downloadThreadInfo = new DownloadThreadInfo();
      downloadThreads.add(downloadThreadInfo);
      inflateDownloadThreadInfo(downloadCursor, downloadThreadInfo);
    }

    downloadInfo.setDownloadThreadInfos(downloadThreads);

  }
  return downloads;
}
 
開發者ID:lifengsofts,項目名稱:AndroidDownloader,代碼行數:32,代碼來源:DefaultDownloadDBController.java

示例12: log_queue_over_logLevel

import android.database.Cursor; //導入方法依賴的package包/類
@Test
public void log_queue_over_logLevel() throws InterruptedException {
  historian.initialize();

  historian.log(Log.INFO, TAG, "this is info1");
  historian.log(Log.DEBUG, TAG, "this is debug1");
  historian.log(Log.INFO, TAG, "this is info2");
  historian.log(Log.WARN, TAG, "this is warn1");
  historian.log(Log.ERROR, TAG, "this is error1");

  Thread.sleep(500);

  Cursor cursor = getAllLogs(historian);

  assertEquals(4, cursor.getCount());

  cursor.moveToFirst();
  assertEquals("INFO", Cursors.getString(cursor, "priority"));
  assertEquals(TAG, Cursors.getString(cursor, "tag"));
  assertEquals("this is info1", Cursors.getString(cursor, "message"));

  cursor.moveToNext();
  assertEquals("INFO", Cursors.getString(cursor, "priority"));
  assertEquals(TAG, Cursors.getString(cursor, "tag"));
  assertEquals("this is info2", Cursors.getString(cursor, "message"));

  cursor.moveToNext();
  assertEquals("WARN", Cursors.getString(cursor, "priority"));
  assertEquals(TAG, Cursors.getString(cursor, "tag"));
  assertEquals("this is warn1", Cursors.getString(cursor, "message"));

  cursor.moveToNext();
  assertEquals("ERROR", Cursors.getString(cursor, "priority"));
  assertEquals(TAG, Cursors.getString(cursor, "tag"));
  assertEquals("this is error1", Cursors.getString(cursor, "message"));

  cursor.close();
}
 
開發者ID:yshrsmz,項目名稱:historian,代碼行數:39,代碼來源:HistorianTest.java

示例13: getAllArtists

import android.database.Cursor; //導入方法依賴的package包/類
public static List<Artist> getAllArtists() {
    List<Artist> artistList = new ArrayList<>();
    Cursor cursor = makeArtistCursor(MusicApplication.getContext());
    // Gather the data
    if (cursor != null && cursor.moveToFirst()) {
        do {
            // Copy the artist id
            final long id = cursor.getLong(0);

            // Copy the artist name
            final String artistName = cursor.getString(1);

            // Copy the number of albums
            final int albumCount = cursor.getInt(2);

            // Copy the number of songs
            final int songCount = cursor.getInt(3);

            // as per designer's request, don't show unknown artist
            if (MediaStore.UNKNOWN_STRING.equals(artistName)) {
                continue;
            }

            // Create a new artist
            final Artist artist = new Artist(id, artistName, songCount, albumCount);
            artistList.add(artist);
        } while (cursor.moveToNext());
    }
    // Close the cursor
    if (cursor != null) {
        cursor.close();
        cursor = null;
    }
    return artistList;
}
 
開發者ID:komamj,項目名稱:KomaMusic,代碼行數:36,代碼來源:ArtistsPresenter.java

示例14: exportSingleIndex

import android.database.Cursor; //導入方法依賴的package包/類
private static void exportSingleIndex(SQLiteDatabase db, String tableName, BufferedWriter writer) throws IOException {
    String sql = "SELECT sql FROM sqlite_master WHERE type = 'index' AND tbl_name='" + tableName + "'";
    Cursor cursor = db.rawQuery(sql, null);
    if (cursor == null) return;

    while (cursor.moveToNext()) {
        if (cursor.getString(0) == null)
            continue;

        writer.write(cursor.getString(0) + ";" + NL + NL);
    }
    cursor.close();
}
 
開發者ID:WeiMei-Tian,項目名稱:editor-sql,代碼行數:14,代碼來源:ExportTool.java

示例15: getAllRecordDetails

import android.database.Cursor; //導入方法依賴的package包/類
public List<RecordDetailsModel> getAllRecordDetails() {
    final List<RecordDetailsModel> listRecordDetails = new ArrayList<>();

    final Cursor cursor = getDatabase().query(DataBaseHelper.TABLE_RECORDS_DETAILS,
            allColumns, null, null, null, null, null);

    cursor.moveToFirst();
    while (!cursor.isAfterLast()) {
        RecordDetailsModel recordDetailsModel = cursorToRecordDetails(cursor);
        listRecordDetails.add(recordDetailsModel);
        cursor.moveToNext();
    }
    cursor.close();
    return listRecordDetails;
}
 
開發者ID:WorldBank-Transport,項目名稱:RoadLab-Pro,代碼行數:16,代碼來源:RecordDetailsDAO.java


注:本文中的android.database.Cursor.moveToNext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。