本文整理汇总了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();
}
}
}
示例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();
}
}
}
示例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;
}