use of android.database.sqlite.SQLiteDatabase in project danci by ling0322.
the class InitActivity method setupDict.
public void setupDict() throws Exception {
//
// first delete this file
//
File f = new File(Config.DICT_12_PATH);
if (f.exists() == true && f.length() > 1 * 1024 * 1024)
return;
if (f.exists() == true && f.length() < 1 * 1024 * 1024)
f.delete();
SQLiteDatabase conn = SQLiteDatabase.openOrCreateDatabase(Config.DICT_12_PATH, null);
conn.beginTransaction();
try {
conn.execSQL("create table dict(word text primary key, definition text)");
for (int i = 0; i < Config.DICT_12_PARTS; ++i) {
BufferedReader in = new BufferedReader(new InputStreamReader(activity.getAssets().open("dict-12-v2.part".concat(Integer.toString(i)))));
String line;
while (null != (line = in.readLine())) {
String[] sp = line.split(" :: ");
conn.execSQL("insert into dict(word, definition) values(?, ?)", sp);
}
sendDisplayMessage(String.format("初始化中, 请稍等 dict-12-v2 %d/%d", i, Config.DICT_12_PARTS));
}
conn.setTransactionSuccessful();
} finally {
conn.endTransaction();
}
conn.close();
}
use of android.database.sqlite.SQLiteDatabase in project ADWLauncher2 by boombuler.
the class AppDBProvider method insert.
@Override
public Uri insert(Uri uri, ContentValues initialValues) {
SqlArguments args = new SqlArguments(uri);
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
final long rowId = db.insert(args.table, null, initialValues);
if (rowId <= 0)
return null;
return ContentUris.withAppendedId(uri, rowId);
}
use of android.database.sqlite.SQLiteDatabase in project FileDownloaderManager by arlyxiao.
the class FileRecord method get_data.
public Map<Integer, Integer> get_data(String path) {
SQLiteDatabase db = db_open_helper.getReadableDatabase();
Cursor cursor = db.rawQuery("select threadid, downlength from filedownlog where downpath=?", new String[] { path });
Map<Integer, Integer> data = new HashMap<Integer, Integer>();
while (cursor.moveToNext()) {
data.put(cursor.getInt(0), cursor.getInt(1));
}
cursor.close();
db.close();
return data;
}
use of android.database.sqlite.SQLiteDatabase in project Brion-Learns-OAuth by brione.
the class BloaProvider method update.
@Override
public int update(Uri uri, ContentValues values, String where, String[] whereArgs) {
int count = 0;
// Get the database and run the query
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
String recId;
String whereClause;
switch(sUriMatcher.match(uri)) {
case USER_STATUS_RECORDS:
count = db.update(USER_STATUS_RECORDS_TABLE_NAME, values, where, whereArgs);
break;
case USER_STATUS_RECORD_ID:
recId = uri.getPathSegments().get(1);
whereClause = UserStatusRecord._ID + "=" + recId + (!TextUtils.isEmpty(where) ? " AND (" + where + ")" : "");
count = db.update(USER_STATUS_RECORDS_TABLE_NAME, values, whereClause, whereArgs);
break;
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
mCR.notifyChange(uri, null);
return count;
}
use of android.database.sqlite.SQLiteDatabase in project Brion-Learns-OAuth by brione.
the class BloaProvider method bulkInsert.
@Override
public int bulkInsert(Uri uri, ContentValues[] values) {
int count = 0;
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
db.beginTransaction();
count = super.bulkInsert(uri, values);
if (count == values.length) {
db.setTransactionSuccessful();
}
db.endTransaction();
return count;
}
Aggregations