本文整理匯總了Java中android.database.CursorIndexOutOfBoundsException類的典型用法代碼示例。如果您正苦於以下問題:Java CursorIndexOutOfBoundsException類的具體用法?Java CursorIndexOutOfBoundsException怎麽用?Java CursorIndexOutOfBoundsException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CursorIndexOutOfBoundsException類屬於android.database包,在下文中一共展示了CursorIndexOutOfBoundsException類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkPosition
import android.database.CursorIndexOutOfBoundsException; //導入依賴的package包/類
private void checkPosition() {
int pos = mInnerCursor.getPosition();
int count = mInnerCursor.getCount();
if (-1 == pos || count == pos) {
throw new CursorIndexOutOfBoundsException(pos, count);
}
}
示例2: getDownloadStatus
import android.database.CursorIndexOutOfBoundsException; //導入依賴的package包/類
public VizContract.Downloads.Status getDownloadStatus(int position) {
Cursor cursor = (Cursor) mAdapter.getItem(position);
// this is cruft left-over from a previous bug which I do not think
// exists anymore b/c we no longer remove a Download behind the users
// back (we used to do this when the download failed)
if (cursor.getCount() == 0) {
return VizContract.Downloads.Status.FAILED;
}
int statusInt = VizContract.Downloads.Status.FAILED.valueOf();
try {
statusInt = cursor.getInt(cursor.getColumnIndex(DownloadsColumns.STATUS));
} catch(CursorIndexOutOfBoundsException e) {
Log.w("threw a cursorIndexOfBoundsException");
}
return VizContract.Downloads.Status.fromInt(statusInt);
}
示例3: getGraphObject
import android.database.CursorIndexOutOfBoundsException; //導入依賴的package包/類
public T getGraphObject()
{
if (this.pos < 0)
throw new CursorIndexOutOfBoundsException("Before first object.");
if (this.pos >= this.graphObjects.size())
throw new CursorIndexOutOfBoundsException("After last object.");
return (GraphObject)this.graphObjects.get(this.pos);
}
示例4: shouldThrowIndexOutOfBoundsExceptionForInvalidColumnLastRow
import android.database.CursorIndexOutOfBoundsException; //導入依賴的package包/類
@Test(expected = CursorIndexOutOfBoundsException.class)
public void shouldThrowIndexOutOfBoundsExceptionForInvalidColumnLastRow() throws Exception {
MatrixCursor cursor = new MatrixCursor(new String[]{"a", "b", "c"});
cursor.addRow(new Object[]{"foo", 10L, 0.1f});
cursor.moveToFirst();
cursor.moveToNext();
cursor.getString(0);
}
示例5: getGraphObject
import android.database.CursorIndexOutOfBoundsException; //導入依賴的package包/類
@Override
public T getGraphObject() {
if (pos < 0) {
throw new CursorIndexOutOfBoundsException("Before first object.");
}
if (pos >= graphObjects.size()) {
throw new CursorIndexOutOfBoundsException("After last object.");
}
return graphObjects.get(pos);
}
示例6: getPassword
import android.database.CursorIndexOutOfBoundsException; //導入依賴的package包/類
public String getPassword() {
SQLiteDatabase db = mDbHelper.getReadableDatabase();
Cursor cursor = db.query(ThreadHelper.DB_USER_TABLE, new String[] { ThreadHelper.DB_PASSWORD },
ThreadHelper.DB_ID + "=?", new String[] { "0" }, null, null, null, null);
if (cursor != null)
cursor.moveToFirst();
try {
return cursor.getString(0);
} catch (CursorIndexOutOfBoundsException e) {
if (th.D) Log.d(TAG, e.getMessage());
}
return null;
}
示例7: getName
import android.database.CursorIndexOutOfBoundsException; //導入依賴的package包/類
public String getName() {
SQLiteDatabase db = mDbHelper.getReadableDatabase();
Cursor cursor = db.query(ThreadHelper.DB_USER_TABLE, new String[] { ThreadHelper.DB_NAME },
ThreadHelper.DB_ID + "=?", new String[] { "0" }, null, null, null, null);
if (cursor != null)
cursor.moveToFirst();
try {
return cursor.getString(0);
} catch (CursorIndexOutOfBoundsException e) {
if (th.D) Log.d(TAG, e.getMessage());
}
return null;
}
示例8: issetUser
import android.database.CursorIndexOutOfBoundsException; //導入依賴的package包/類
public boolean issetUser() {
SQLiteDatabase db = mDbHelper.getReadableDatabase();
try {
Cursor cursor = db.query(ThreadHelper.DB_USER_TABLE, new String[] { ThreadHelper.DB_NAME },
ThreadHelper.DB_ID + "=?", new String[] { "0" }, null, null, null, null);
if (cursor != null)
cursor.moveToFirst();
cursor.getString(0);
return true;
} catch (CursorIndexOutOfBoundsException e) {
if (th.D) Log.d(TAG, e.getMessage());
}
return false;
}
示例9: getPublicKey
import android.database.CursorIndexOutOfBoundsException; //導入依賴的package包/類
public String getPublicKey() {
String result = null;
SQLiteDatabase db = mDbHelper.getReadableDatabase();
Cursor cursor = db.query(ThreadHelper.DB_USER_TABLE, new String[] { ThreadHelper.DB_PUBLIC },
ThreadHelper.DB_ID + "=?", new String[] { "0" }, null, null, null, null);
try {
if (cursor != null)
cursor.moveToFirst();
result = cursor.getString(0);
} catch (CursorIndexOutOfBoundsException e) {
if (th.D) Log.d(TAG, e.getMessage());
}
return result;
}
示例10: getPrivateKey
import android.database.CursorIndexOutOfBoundsException; //導入依賴的package包/類
public String getPrivateKey() {
String result = null;
SQLiteDatabase db = mDbHelper.getReadableDatabase();
Cursor cursor = db.query(ThreadHelper.DB_USER_TABLE, new String[] { ThreadHelper.DB_PRIVATE },
ThreadHelper.DB_ID + "=?", new String[] { "0" }, null, null, null, null);
try {
if (cursor != null)
cursor.moveToFirst();
result = cursor.getString(0);
} catch (CursorIndexOutOfBoundsException e) {
if (th.D) Log.d(TAG, e.getMessage());
}
return result;
}
示例11: getContactsEmailAddress
import android.database.CursorIndexOutOfBoundsException; //導入依賴的package包/類
/**
* Get the main email address of the contact
* @param contactID The last known ContactID of the contact
* @param c The context to run in
* @return String representation of their email address
* @throws android.database.CursorIndexOutOfBoundsException
*/
public static HashMap<String,String> getContactsEmailAddress(String contactID, Context c) throws CursorIndexOutOfBoundsException
{
/*
* For some shitting reason, using ContactsContract.CommonDataKinds.Phone works instead of Email?
* Leaving it anyway, might just be some stupid HTC Sense 5 bug
*/
HashMap<String,String> emails = new HashMap<String,String>();
for(int i=0;i<=typesEmail.length-1;i++){
String[] whereArgs = new String[] {String.valueOf(contactID), String.valueOf(typesEmail[i])};
String email = queryContactForEmail(c, whereArgs);
if(email!=null){
if(ContactsContract.CommonDataKinds.Phone.TYPE_HOME==typesEmail[i]){
emails.put("Home", email);
}
else if(ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE==typesEmail[i]){
emails.put("Other", email);
}
else if(ContactsContract.CommonDataKinds.Phone.TYPE_WORK==typesEmail[i]){
emails.put("Work", email);
}
}
}
return emails;
}
示例12: getMostRecentDebt
import android.database.CursorIndexOutOfBoundsException; //導入依賴的package包/類
/**
* Lookup the most recent entry in the database
* @return Debt representation of most recent debt entered into database
* @throws java.text.ParseException
* @throws NullPointerException
* @throws android.database.sqlite.SQLiteException
* @throws android.database.CursorIndexOutOfBoundsException
*/
public Debt getMostRecentDebt() throws ParseException, NullPointerException, SQLiteException,
CursorIndexOutOfBoundsException{
SQLiteDatabase db = getReadableDatabase();
Cursor c;
c = db.query(Names.D_TABLENAME, null, null, null, null, null, null);
c.moveToLast();
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
db.close();
return new Debt(c.getInt(0), c.getString(1), sdf.parse(c.getString(2)),
new BigDecimal(c.getString(2)), c.getString(3));
}
示例13: doInBackground
import android.database.CursorIndexOutOfBoundsException; //導入依賴的package包/類
@Override
protected String doInBackground(String... sUrl) {
sqliteHelper = new SQLiteOpenHelperCurrency(
ConverterInterface.thisContext);
String[] code = new String[1];
db = sqliteHelper.getReadableDatabase();
Cursor cursor = null;
try {
for (int n = 0; n <= currencyCodes.length - 1; n++) {
for (int k = 0; k <= currencyCodes.length - 1; k++) {
code[0] = String.valueOf(n * (currencyCodes.length) + k
+ 1);
cursor = db.rawQuery(
"SELECT currency from currencies WHERE _id=?",
code);
cursor.moveToFirst();
currencies[n][k] = Double.valueOf(cursor
.getString(cursor.getColumnIndex("currency")));
cursor.close();
}
}
} catch (CursorIndexOutOfBoundsException e) {
Converter.CurrencyDatabase.delete();
} finally {
if (cursor != null)
cursor.close();
}
publishProgress(0);
return null;
}