Android SQLiteCursor - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android SQLiteCursor class.

This code example shows how to use the following methods: getColumnIndexOrThrow
 
    @Test(expected = IllegalArgumentException.class) 
    public void testGetColumnIndexOrThrowNotFoundEmpty() throws Exception { 
        setupEmptyResult(); 
 
        cursor.getColumnIndexOrThrow("Fred");
    } 
 
    @Test 
    public void testMoveToFirst() throws Exception { 
        assertThat(cursor.moveToFirst(), equalTo(true));
        assertThat(cursor.getInt(0), equalTo(1234));
        assertThat(cursor.getString(1), equalTo("Chuck"));
    } 
 
    @Test 
    public void testMoveToFirstEmpty() throws Exception { 
        setupEmptyResult(); 
 
        assertThat(cursor.moveToFirst(), equalTo(false));

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: moveToFirst, getString, close, getColumnIndex
            db = this.openOrCreateDatabase("/data/data/info.hagedev.itscool/databases/timetable", SQLiteDatabase.OPEN_READWRITE, null);
         } 
 
        q = "SELECT TimetableURL FROM Routes WHERE Departure = '"+dept+"' AND Arrival ='"+arvl+"';";
        cursor = (SQLiteCursor)db.rawQuery(q, null);
        if(cursor.moveToFirst()){
        		url = cursor.getString(cursor.getColumnIndex("TimetableURL"));
        } 
        db.close();
        cursor.close();
 
        Log.d("query",q);
        Log.d("departure",dept);
        Log.d("arrival", arvl);
        Log.d("url", url);
 
 
        intent.putExtra("departure", dept);
        intent.putExtra("arrival", arvl);
        intent.putExtra("url", url);
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
This code example shows how to use the following methods: moveToFirst, getDouble
	} 
	 
	public Double[] getLatLngForId(long id) {
		SQLiteDatabase db = this.getReadableDatabase();
		SQLiteCursor c = (SQLiteCursor) db.rawQuery("SELECT lat,lng FROM locations WHERE "+BaseColumns._ID+"="+Long.toString(id), null);
		c.moveToFirst();
		Double[] r = { c.getDouble(0), c.getDouble(1) };
		return r;		
	} 
	 
	public void deleteId(long id) {
		SQLiteDatabase db = this.getWritableDatabase();
		db.delete(LOCATIONS_TABLE_NAME, BaseColumns._ID+"="+Long.toString(id),null);	
	} 
} 
	 
 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getLong, getString
 
    @Override 
    public boolean onContextItemSelected(MenuItem item) {
    	AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
        SQLiteCursor  cursor = (SQLiteCursor) getListView().getItemAtPosition(info.position);
        startManagingCursor(cursor);
        final Long suraID = cursor.getLong(1);
        final Long verseID = cursor.getLong(2);
        String verseText = cursor.getString(3);
 
        switch(item.getItemId()) {
            case COPY_ID:
            	clipboard.setText("'"+verseText+"' Al-Quran ("+suraID+":"+verseID+") (Quran360 for Android)");
                Toast.makeText(getApplicationContext(), clipboard.getText().toString(), Toast.LENGTH_SHORT).show();
               return true; 
            case CHECKPOINT_ID:
            	myDBHelper.editReadPoint(suraID, verseID, verseText);
                return true;                                 
            case BOOKMARK_ID:
            	myDBHelper.addBookmark("("+suraID+":"+verseID+")", suraID, verseID, (verseID-1), verseText);
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android SQLiteCursor Questions & Answers:

See Code Examples for Android SQLiteCursor Methods: