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


Java SQLiteAssetHelper類代碼示例

本文整理匯總了Java中com.readystatesoftware.sqliteasset.SQLiteAssetHelper的典型用法代碼示例。如果您正苦於以下問題:Java SQLiteAssetHelper類的具體用法?Java SQLiteAssetHelper怎麽用?Java SQLiteAssetHelper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: deleteAll

import com.readystatesoftware.sqliteasset.SQLiteAssetHelper; //導入依賴的package包/類
public static void deleteAll(SQLiteAssetHelper helper) throws IOException {

        SQLiteDatabase db = null;
        Cursor c = null;
        try {


            db = helper.getWritableDatabase();

            db.execSQL("delete from " + TABLE_NAME);


        } finally {
            if (db != null) {
                if (c != null)
                    c.close();
                db.close();
            }
        }
    }
 
開發者ID:slartus,項目名稱:4pdaClient-plus,代碼行數:21,代碼來源:NotesTable.java

示例2: insertNote

import com.readystatesoftware.sqliteasset.SQLiteAssetHelper; //導入依賴的package包/類
public static void insertNote(SQLiteAssetHelper helper, Note note) {
    SQLiteDatabase db = null;

    try {

        db = helper.getWritableDatabase();
        // db.beginTransaction();

        ContentValues values = new ContentValues();

        values.put(COLUMN_TITLE, note.Title);
        values.put(COLUMN_BODY, note.Body);
        values.put(COLUMN_URL, note.Url);
        values.put(COLUMN_TOPIC_ID, note.TopicId);
        values.put(COLUMN_POST_ID, note.PostId);
        values.put(COLUMN_USER_ID, note.UserId);
        values.put(COLUMN_USER, note.User);
        values.put(COLUMN_TOPIC, note.Topic);
        values.put(COLUMN_DATE, DbHelper.DateTimeFormat.format(note.Date));


        db.insertOrThrow(TABLE_NAME, null, values);

    } catch (Exception ex) {
        AppLog.e(App.getInstance(), ex);
    } finally {
        if (db != null) {
            // db.endTransaction();
            db.close();
        }
    }
}
 
開發者ID:slartus,項目名稱:4pdaClient-plus,代碼行數:33,代碼來源:NotesTable.java

示例3: getNotes

import com.readystatesoftware.sqliteasset.SQLiteAssetHelper; //導入依賴的package包/類
public static ArrayList<Note> getNotes(SQLiteAssetHelper helper, String topicId) throws ParseException, IOException {
    ArrayList<Note> notes = new ArrayList<Note>();

    SQLiteDatabase db = null;
    Cursor c = null;
    try {

        db = helper.getWritableDatabase();
        String selection = null;
        String[] selectionArgs = null;

        if (!TextUtils.isEmpty(topicId)) {
            selection = COLUMN_TOPIC_ID + "=?";
            selectionArgs = new String[]{topicId};
        }
        c = db.query(TABLE_NAME, null, selection, selectionArgs, null, null, COLUMN_DATE + " DESC");

        if (c.moveToFirst()) {
            int columnIdIndex = c.getColumnIndex(COLUMN_ID);
            int columnTitleIndex = c.getColumnIndex(COLUMN_TITLE);
            int columnBodyIndex = c.getColumnIndex(COLUMN_BODY);
            int columnUrlIndex = c.getColumnIndex(COLUMN_URL);
            int columnTopicIdIndex = c.getColumnIndex(COLUMN_TOPIC_ID);
            int columnPostIdIndex = c.getColumnIndex(COLUMN_POST_ID);
            int columnUserIdIndex = c.getColumnIndex(COLUMN_USER_ID);
            int columnUserIndex = c.getColumnIndex(COLUMN_USER);
            int columnTopicIndex = c.getColumnIndex(COLUMN_TOPIC);
            int columnDateIndex = c.getColumnIndex(COLUMN_DATE);
            do {
                Note note = new Note();
                note.Id = c.getString(columnIdIndex);
                note.Title = c.getString(columnTitleIndex);
                note.Body = c.getString(columnBodyIndex);
                note.Url = c.getString(columnUrlIndex);
                note.TopicId = c.getString(columnTopicIdIndex);
                note.PostId = c.getString(columnPostIdIndex);
                note.UserId = c.getString(columnUserIdIndex);
                note.User = c.getString(columnUserIndex);
                note.Topic = c.getString(columnTopicIndex);
                note.Date = DbHelper.parseDate(c.getString(columnDateIndex));
                notes.add(note);
            } while (c.moveToNext());
        }
    } finally {
        if (db != null) {
            if (c != null)
                c.close();
            db.close();
        }
    }

    return notes;
}
 
開發者ID:slartus,項目名稱:4pdaClient-plus,代碼行數:54,代碼來源:NotesTable.java


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