本文整理汇总了Java中android.database.sqlite.SQLiteDatabase.isOpen方法的典型用法代码示例。如果您正苦于以下问题:Java SQLiteDatabase.isOpen方法的具体用法?Java SQLiteDatabase.isOpen怎么用?Java SQLiteDatabase.isOpen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.database.sqlite.SQLiteDatabase
的用法示例。
在下文中一共展示了SQLiteDatabase.isOpen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveMessage
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
/**
* save a message
*
* @param message
* @return return cursor of the message
*/
public synchronized Integer saveMessage(InviteMessage message) {
SQLiteDatabase db = dbHelper.getWritableDatabase();
int id = -1;
if (db.isOpen()) {
ContentValues values = new ContentValues();
values.put(InviteMessgeDao.COLUMN_NAME_FROM, message.getFrom());
values.put(InviteMessgeDao.COLUMN_NAME_GROUP_ID, message.getGroupId());
values.put(InviteMessgeDao.COLUMN_NAME_GROUP_Name, message.getGroupName());
values.put(InviteMessgeDao.COLUMN_NAME_REASON, message.getReason());
values.put(InviteMessgeDao.COLUMN_NAME_TIME, message.getTime());
values.put(InviteMessgeDao.COLUMN_NAME_STATUS, message.getStatus().ordinal());
values.put(InviteMessgeDao.COLUMN_NAME_GROUPINVITER, message.getGroupInviter());
db.insert(InviteMessgeDao.TABLE_NAME, null, values);
Cursor cursor = db.rawQuery("select last_insert_rowid() from " + InviteMessgeDao.TABLE_NAME, null);
if (cursor.moveToFirst()) {
id = cursor.getInt(0);
}
cursor.close();
}
return id;
}
示例2: isFieldExists
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public static boolean isFieldExists(SQLiteDatabase db, String tableName, String fieldName) {
if (tableName == null || db == null || fieldName == null || !db.isOpen()) return false;
Cursor cursor = null;
try {
cursor = db.rawQuery("SELECT * FROM " + tableName + " LIMIT 0", null);
return cursor != null && cursor.getColumnIndex(fieldName) != -1;
} catch (Exception e) {
OkLogger.printStackTrace(e);
return false;
} finally {
if (cursor != null) {
cursor.close();
}
}
}
示例3: DisplayUploadFile
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public void DisplayUploadFile(){
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
if (db != null && db.isOpen()) {
Cursor cur = db.rawQuery("select upload_file_name, isForceUpload, isResend from file_info",
new String[]{});
if (!cur.isClosed()) {
try{
while(cur.moveToNext()){
Log.i(TAG, "upload_file_name: " + cur.getString(0) + " isForceUpload: " + cur.getInt(1) + " isResend: " + cur.getInt(2));
}
} catch(Exception ex){
Log.i(TAG, ex.toString());
} finally{
cur.close();
db.close();
}
}
}
}
示例4: getBindId
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public String getBindId(File uploadFile){
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
String bindID = null;
if (db != null && db.isOpen()) {
Cursor cur = db.rawQuery("select sourceid from uploadlog where uploadfilepath=?",
new String[]{uploadFile.getAbsolutePath()});
if (!cur.isClosed()) {
try{
if(cur.moveToFirst()){
bindID = cur.getString(0);
}
} catch(Exception ex){
} finally{
cur.close();
db.close();
}
}
}
return bindID;
}
示例5: updateMessage
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
/**
* update message
*
* @param msgId
* @param values
*/
synchronized public void updateMessage(int msgId, ContentValues values) {
SQLiteDatabase db = dbHelper.getWritableDatabase();
if (db.isOpen()) {
db.update(InviteMessgeDao.TABLE_NAME, values, InviteMessgeDao.COLUMN_NAME_ID + " = ?", new String[]{String.valueOf(msgId)});
}
}
示例6: insertVideoPosition
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public static void insertVideoPosition(String videoId, int position) {
SQLiteDatabase database = sqLiteOpenHelper.getWritableDatabase();
if (database.isOpen()) {
ContentValues values = new ContentValues();
values.put("videoId", videoId);
values.put("position", position);
database.insert(VIDEOPOSITION, null, values);
database.close();
}
}
示例7: getVideoPosition
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public static int getVideoPosition(String videoId) {
int position = 0;
SQLiteDatabase database = sqLiteOpenHelper.getReadableDatabase();
if (database.isOpen()) {
Cursor cursor = database.query(VIDEOPOSITION, new String[]{"position"}, "videoId=?", new String[]{videoId}, null, null, null);
if (cursor.moveToFirst()) {
position = cursor.getInt(cursor.getColumnIndex("position"));
}
cursor.close();
database.close();
}
return position;
}
示例8: updateVideoPosition
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public static void updateVideoPosition(String videoId, int position) {
SQLiteDatabase database = sqLiteOpenHelper.getWritableDatabase();
if (database.isOpen()) {
ContentValues values = new ContentValues();
values.put("position", position);
database.update(VIDEOPOSITION, values, "videoId=?", new String[]{videoId});
database.close();
}
}
示例9: getFileInfo
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
public FileInfo getFileInfo(String uploadFileName){
FileInfo fileInfo = new FileInfo();
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
if (db != null && db.isOpen()) {
Cursor cur = db.rawQuery("select upload_file_name, isForceUpload, isResend from file_info where upload_file_name = ?",
new String[]{uploadFileName});
if (!cur.isClosed()) {
try{
while(cur.moveToNext()){
if (cur.getInt(1) == 0) {
fileInfo.isForceUpload = false;
} else {
fileInfo.isForceUpload = true;
}
if (cur.getInt(2) == 0) {
fileInfo.isResend = false;
} else {
fileInfo.isResend = true;
}
}
} catch(Exception ex){
} finally{
cur.close();
db.close();
}
}
}
return fileInfo;
}
示例10: getUnreadNotifyCount
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
synchronized int getUnreadNotifyCount() {
int count = 0;
SQLiteDatabase db = dbHelper.getReadableDatabase();
if (db.isOpen()) {
Cursor cursor = db.rawQuery("select " + InviteMessgeDao.COLUMN_NAME_UNREAD_MSG_COUNT + " from " + InviteMessgeDao.TABLE_NAME, null);
if (cursor.moveToFirst()) {
count = cursor.getInt(0);
}
cursor.close();
}
return count;
}
示例11: setUnreadNotifyCount
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
synchronized void setUnreadNotifyCount(int count) {
SQLiteDatabase db = dbHelper.getWritableDatabase();
if (db.isOpen()) {
ContentValues values = new ContentValues();
values.put(InviteMessgeDao.COLUMN_NAME_UNREAD_MSG_COUNT, count);
db.update(InviteMessgeDao.TABLE_NAME, values, null, null);
}
}
示例12: setList
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
synchronized private void setList(String column, List<String> strList) {
StringBuilder strBuilder = new StringBuilder();
for (String hxid : strList) {
strBuilder.append(hxid).append("$");
}
SQLiteDatabase db = dbHelper.getWritableDatabase();
if (db.isOpen()) {
ContentValues values = new ContentValues();
values.put(column, strBuilder.toString());
db.update(UserDao.PREF_TABLE_NAME, values, null, null);
}
}
示例13: getContactList
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
/**
* get contact list
*
* @return
*/
synchronized public Map<String, EaseUser> getContactList() {
SQLiteDatabase db = dbHelper.getReadableDatabase();
Map<String, EaseUser> users = new Hashtable<String, EaseUser>();
if (db.isOpen()) {
Cursor cursor = db.rawQuery("select * from " + UserDao.TABLE_NAME /* + " desc" */, null);
while (cursor.moveToNext()) {
String username = cursor.getString(cursor.getColumnIndex(UserDao.COLUMN_NAME_ID));
String nick = cursor.getString(cursor.getColumnIndex(UserDao.COLUMN_NAME_NICK));
String avatar = cursor.getString(cursor.getColumnIndex(UserDao.COLUMN_NAME_AVATAR));
String phone = cursor.getString(cursor.getColumnIndex(UserDao.COLUMN_NAME_PHONE));
String postion = cursor.getString(cursor.getColumnIndex(UserDao.ROBOT_COLUMN_NAME_POSITION));
String company = cursor.getString(cursor.getColumnIndex(UserDao.ROBOT_COLUMN_NAME_COMPANY));
String nickName = cursor.getString(cursor.getColumnIndex(UserDao.ROBOT_COLUMN_NAME_NICKNAME));
String memberid = cursor.getString(cursor.getColumnIndex(UserDao.COLUMN_NAME_MEMBER_ID));
EaseUser user = new EaseUser(username);
user.setNick(nick);
user.setNewnickName(nickName);
user.setAvatar(avatar);
user.setPhone(phone);
try {
user.setMemberId(Integer.valueOf(memberid));
} catch (Exception e) {
}
user.setPosition(postion);
user.setCompany(company);
if (username.equals(Constant.NEW_FRIENDS_USERNAME) || username.equals(Constant.GROUP_USERNAME)
|| username.equals(Constant.CHAT_ROOM) || username.equals(Constant.CHAT_ROBOT)) {
user.setInitialLetter("");
} else {
EaseCommonUtils.setUserInitialLetter(user);
}
users.put(username, user);
}
cursor.close();
}
return users;
}
示例14: deleteContact
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
/**
* delete a contact
*
* @param username
*/
synchronized public void deleteContact(String username) {
SQLiteDatabase db = dbHelper.getWritableDatabase();
if (db.isOpen()) {
db.delete(UserDao.TABLE_NAME, UserDao.COLUMN_NAME_ID + " = ?", new String[]{username});
}
}
示例15: closeDatabase
import android.database.sqlite.SQLiteDatabase; //导入方法依赖的package包/类
/**
* Cierra la base de datos
* @param db conexión a base de dato a cerrar
*/
public void closeDatabase (SQLiteDatabase db) {
if (db != null && db.isOpen()) {
db.close();
}
}