本文整理汇总了Java中android.database.Cursor.getInt方法的典型用法代码示例。如果您正苦于以下问题:Java Cursor.getInt方法的具体用法?Java Cursor.getInt怎么用?Java Cursor.getInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.database.Cursor
的用法示例。
在下文中一共展示了Cursor.getInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: mapFromCursor
import android.database.Cursor; //导入方法依赖的package包/类
@NonNull
@Override
public StockUpdate mapFromCursor(@NonNull Cursor cursor) {
final int id = cursor.getInt(cursor.getColumnIndexOrThrow(StockUpdateTable.Columns.ID));
final long dateLong = cursor.getLong(cursor.getColumnIndexOrThrow(StockUpdateTable.Columns.DATE));
final long priceLong = cursor.getLong(cursor.getColumnIndexOrThrow(StockUpdateTable.Columns.PRICE));
final String stockSymbol = cursor.getString(cursor.getColumnIndexOrThrow(StockUpdateTable.Columns.STOCK_SYMBOL));
final String twitterStatus = cursor.getString(cursor.getColumnIndexOrThrow(StockUpdateTable.Columns.TWITTER_STATUS));
Date date = getDate(dateLong);
BigDecimal price = getPrice(priceLong);
final StockUpdate stockUpdate = new StockUpdate(
stockSymbol,
price,
date,
twitterStatus
);
stockUpdate.setId(id);
return stockUpdate;
}
示例3: getAllFinishLatestThreeDownLoadTrace
import android.database.Cursor; //导入方法依赖的package包/类
public DownloadDBListBean getAllFinishLatestThreeDownLoadTrace() {
try {
Cursor cursor = this.mContext.getContentResolver().query(LetvContentProvider.URI_DOWNLOADTRACE, null, "finish=?", new String[]{"4"}, "timestamp DESC");
DownloadDBListBean arrayList = new DownloadDBListBean();
ArrayList<Integer> albumIdList = new ArrayList();
int count = 0;
while (cursor.moveToNext() && count < 3) {
DownloadDBBean mDownloadDBBean = new DownloadDBBean();
int albumId = cursor.getInt(cursor.getColumnIndex(PageJumpUtil.IN_TO_ALBUM_PID));
mDownloadDBBean.aid = albumId;
mDownloadDBBean.episodetitle = cursor.getString(cursor.getColumnIndex("episodetitle"));
mDownloadDBBean.albumtitle = cursor.getString(cursor.getColumnIndex(DownloadAlbumTable.COLUMN_ALBUMTITLE));
if (!albumIdList.contains(Integer.valueOf(albumId))) {
albumIdList.add(Integer.valueOf(albumId));
arrayList.add(mDownloadDBBean);
count++;
}
}
LetvTools.closeCursor(cursor);
return arrayList;
} catch (Throwable th) {
LetvTools.closeCursor(null);
}
}
示例4: getImageContentUri
import android.database.Cursor; //导入方法依赖的package包/类
public Uri getImageContentUri(File imageFile) {
String filePath = imageFile.getAbsolutePath();
Cursor cursor = getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[]{MediaStore.Images.Media._ID},
MediaStore.Images.Media.DATA + "=? ",
new String[]{filePath}, null);
if (cursor != null && cursor.moveToFirst()) {
int id = cursor.getInt(cursor.getColumnIndex(MediaStore.MediaColumns._ID));
Uri baseUri = Uri.parse("content://media/external/images/media");
cursor.close();
return Uri.withAppendedPath(baseUri, "" + id);
} else {
if (imageFile.exists()) {
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.DATA, filePath);
if (cursor != null) {
cursor.close();
}
return getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
} else {
return null;
}
}
}
示例5: getDictInfo
import android.database.Cursor; //导入方法依赖的package包/类
@Nullable //if null, not found
public CustomDictionaryInformation getDictInfo(int dictId){
Cursor cursor = getReadableDatabase().query(
TB_DICT,
new String[] {CL_ID, CL_NAME, CL_DESCRIPTION, CL_LANG, CL_TMPL, CL_ELEMENTS},
CL_ID + "=" + dictId,
null,
null,
null,
null
);
CustomDictionaryInformation customDictionaryInformation = null;
while(cursor.moveToNext()){
customDictionaryInformation = new CustomDictionaryInformation(
cursor.getInt(0),
cursor.getString(1),
cursor.getString(2),
cursor.getString(3),
cursor.getString(4),
fromFieldsString(cursor.getString(5))
);
}
return customDictionaryInformation;
}
示例6: insertMusicInfoToMusicTable
import android.database.Cursor; //导入方法依赖的package包/类
public void insertMusicInfoToMusicTable(MusicInfo musicInfo) {
ContentValues values;
Cursor cursor = null;
int id = 1;
try {
values = musicInfoToContentValues(musicInfo);
String sql = "select max(id) from " + DatabaseHelper.MUSIC_TABLE + ";";
cursor = db.rawQuery(sql, null);
if (cursor.moveToFirst()) {
//设置新添加的ID为最大ID+1
id = cursor.getInt(0) + 1;
}
values.put(ID_COLUMN, id);
// values.put("mylove",0);
db.insert(DatabaseHelper.MUSIC_TABLE, null, values);
} catch (Exception e) {
e.printStackTrace();
if (cursor!=null){
cursor.close();
}
}
}
示例7: queryIfIDExists
import android.database.Cursor; //导入方法依赖的package包/类
private boolean queryIfIDExists(int id){
Cursor cursor = db.query("Douban",null,null,null,null,null,null);
if (cursor.moveToFirst()){
do {
if (id == cursor.getInt(cursor.getColumnIndex("douban_id"))){
return true;
}
} while (cursor.moveToNext());
}
cursor.close();
return false;
}
示例8: onClick
import android.database.Cursor; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
if(photoPageAdapter == null) return;
Cursor c = (Cursor)photoPageAdapter.getDataItem(currentID);
String type = c.getString(MediaSetUtils.INDEX_ITEM_TYPE);
int rowID = c.getInt(MediaSetUtils.INDEX_ID);
boolean image = PicShowUtils.isImage(type);
Uri baseUri = image ? MediaStore.Images.Media.EXTERNAL_CONTENT_URI :
MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
Uri u = baseUri.buildUpon().appendPath(String.valueOf(rowID)).build();
switch (v.getId()) {
case R.id.share:
menuExecutor.execute(MenuExecutor.MENU_ACTION_SHARE, u, image);
break;
case R.id.edit:
menuExecutor.execute(MenuExecutor.MENU_ACTION_SHARE, u, image);
break;
case R.id.delete:
menuExecutor.execute(MenuExecutor.MENU_ACTION_DELETE, u, image);
break;
case R.id.more:
showMoreMenu();
break;
}
}
示例9: downloadWithSystemManager
import android.database.Cursor; //导入方法依赖的package包/类
@ProtoMethod(description = "Downloads a file from a given Uri. Returns the progress", example = "")
public void downloadWithSystemManager(String url, final ReturnInterface callback) {
final DownloadManager dm = (DownloadManager) getContext().getSystemService(getContext().DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
final long enqueue = dm.enqueue(request);
BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);
DownloadManager.Query query = new DownloadManager.Query();
query.setFilterById(enqueue);
Cursor c = dm.query(query);
if (c.moveToFirst()) {
int columnIndex = c
.getColumnIndex(DownloadManager.COLUMN_STATUS);
if (DownloadManager.STATUS_SUCCESSFUL == c.getInt(columnIndex)) {
if (callback != null) callback.event(null);
// callback successful
}
}
}
}
};
getContext().registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
}
示例10: queryIfIDExists
import android.database.Cursor; //导入方法依赖的package包/类
private boolean queryIfIDExists(int id){
Cursor cursor = db.query("Guokr",null,null,null,null,null,null);
if (cursor.moveToFirst()){
do {
if (id == cursor.getInt(cursor.getColumnIndex("guokr_id"))){
return true;
}
} while (cursor.moveToNext());
}
cursor.close();
return false;
}
示例11: 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;
}
示例12: createPlaylist
import android.database.Cursor; //导入方法依赖的package包/类
public static int createPlaylist(@NonNull final Context context, @Nullable final String name) {
int id = -1;
if (name != null && name.length() > 0) {
try {
Cursor cursor = context.getContentResolver().query(EXTERNAL_CONTENT_URI,
new String[]{MediaStore.Audio.Playlists._ID}, MediaStore.Audio.PlaylistsColumns.NAME + "=?", new String[]{name}, null);
if (cursor == null || cursor.getCount() < 1) {
final ContentValues values = new ContentValues(1);
values.put(MediaStore.Audio.PlaylistsColumns.NAME, name);
final Uri uri = context.getContentResolver().insert(
EXTERNAL_CONTENT_URI,
values);
if (uri != null) {
// necessary because somehow the MediaStoreObserver is not notified when adding a playlist
context.getContentResolver().notifyChange(Uri.parse("content://media"), null);
Toast.makeText(context, context.getResources().getString(
R.string.created_playlist_x, name), Toast.LENGTH_SHORT).show();
id = Integer.parseInt(uri.getLastPathSegment());
}
} else {
if (cursor.moveToFirst()) {
id = cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Playlists._ID));
}
}
if (cursor != null) {
cursor.close();
}
} catch (SecurityException ignored) {
}
}
if (id == -1) {
Toast.makeText(context, context.getResources().getString(
R.string.could_not_create_playlist), Toast.LENGTH_SHORT).show();
}
return id;
}
示例13: getItemCount
import android.database.Cursor; //导入方法依赖的package包/类
/**
* 统计查询 此处查询Country为China的用户总数,***待修改***
*/
public int getItemCount(int sql) {//**//
int count = 0;
SQLiteDatabase db = null;
Cursor cursor = null;
try {
db = ordersDBHelper.getReadableDatabase();
// select count(Id) from Orders where Country = 'China'
cursor = db.query(OrderDBHelper.TABLE_item,
new String[]{"COUNT(ID)"},
"ID = ?",
new String[]{String.valueOf(sql)},
null, null, null);
if (cursor.moveToFirst()) {
count = cursor.getInt(0);
}
}
catch (Exception e) {
Log.e(TAG, "", e);
}
finally {
if (cursor != null) {
cursor.close();
}
if (db != null) {
db.close();
}
}
return count;
}
示例14: getCurrentDownloadingDBBean
import android.database.Cursor; //导入方法依赖的package包/类
public DownloadDBBean getCurrentDownloadingDBBean() {
Cursor cursor = null;
try {
cursor = this.mContext.getContentResolver().query(LetvContentProvider.URI_DOWNLOADTRACE, null, "finish==", new String[]{"1"}, "timestamp ASC");
DownloadDBBean downloadDBBean = null;
while (cursor.moveToNext()) {
downloadDBBean = new DownloadDBBean();
downloadDBBean.vid = cursor.getInt(cursor.getColumnIndex("episodeid"));
downloadDBBean.aid = cursor.getInt(cursor.getColumnIndex(PageJumpUtil.IN_TO_ALBUM_PID));
downloadDBBean.icon = cursor.getString(cursor.getColumnIndex(SettingsJsonConstants.APP_ICON_KEY));
downloadDBBean.type = cursor.getInt(cursor.getColumnIndex("type"));
downloadDBBean.ord = (float) cursor.getInt(cursor.getColumnIndex("ord"));
downloadDBBean.cid = cursor.getInt(cursor.getColumnIndex("cid"));
downloadDBBean.episodetitle = cursor.getString(cursor.getColumnIndex("episodetitle"));
downloadDBBean.episodeIcon = cursor.getString(cursor.getColumnIndex("episodeicon"));
downloadDBBean.albumtitle = cursor.getString(cursor.getColumnIndex(DownloadAlbumTable.COLUMN_ALBUMTITLE));
downloadDBBean.totalsize = cursor.getLong(cursor.getColumnIndex(DownloadVideoTable.COLUMN_TOTALSIZE));
downloadDBBean.finish = cursor.getInt(cursor.getColumnIndex("finish"));
downloadDBBean.timestamp = cursor.getLong(cursor.getColumnIndex("timestamp"));
downloadDBBean.length = cursor.getLong(cursor.getColumnIndex(DownloadVideoTable.COLUMN_LENGTH));
downloadDBBean.filePath = cursor.getString(cursor.getColumnIndex("file_path"));
downloadDBBean.isHd = cursor.getInt(cursor.getColumnIndex("isHd"));
downloadDBBean.isNew = cursor.getInt(cursor.getColumnIndex(DownloadVideoTable.COLUMN_ISNEW));
downloadDBBean.btime = cursor.getLong(cursor.getColumnIndex(DownloadVideoTable.COLUMN_BTIME));
downloadDBBean.etime = cursor.getLong(cursor.getColumnIndex(DownloadVideoTable.COLUMN_ETIME));
downloadDBBean.duration = cursor.getLong(cursor.getColumnIndex(DownloadVideoTable.COLUMN_DURATION));
}
return downloadDBBean;
} finally {
LetvTools.closeCursor(cursor);
}
}
示例15: getDetalheAtividade
import android.database.Cursor; //导入方法依赖的package包/类
public Atividade getDetalheAtividade(int id) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(TABLE_ATIVIDADE,
new String[]{Atividade.TAG_ID,
Atividade.TAG_TITULO,
Atividade.TAG_PREDIO,
Atividade.TAG_SALA,
Atividade.TAG_DESCRICAO,
Atividade.TAG_HORARIOS,
Atividade.TAG_TIPO,
Atividade.TAG_ULTIMA_ATUALIZACAO,
Atividade.TAG_FAVORITO},
Atividade.TAG_ID + "=?",
new String[]{String.valueOf(id)}, null, null, null, null);
Atividade atividade = new Atividade();
if (cursor.moveToFirst()) {
atividade.setId(id);
atividade.setTitulo(cursor.getString(1));
atividade.setLocal(cursor.getString(2), cursor.getString(3));
atividade.setDescricao(cursor.getString(4));
atividade.setHorarios(cursor.getString(5));
atividade.setTipo(cursor.getString(6));
atividade.setHorarioUltimaAtualizacao(cursor.getString(7));
if (cursor.getInt(8) == 1) {
atividade.setFavorito(true);
}
}
cursor.close();
db.close();
List<Pessoa> ministrantes = getMinistrantes(atividade);
atividade.setMinistrantes(ministrantes);
return atividade;
}