本文整理了Java中android.app.Activity.openOrCreateDatabase()
方法的一些代码示例,展示了Activity.openOrCreateDatabase()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.openOrCreateDatabase()
方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:openOrCreateDatabase
暂无
代码示例来源:origin: com.uphyca/android-junit4-robolectric
/**
* @param name
* @param mode
* @param factory
* @return
* @see android.content.ContextWrapper#openOrCreateDatabase(java.lang.String,
* int, android.database.sqlite.SQLiteDatabase.CursorFactory)
*/
public SQLiteDatabase openOrCreateDatabase(String name,
int mode,
CursorFactory factory) {
return mActivity.openOrCreateDatabase(name, mode, factory);
}
代码示例来源:origin: com.uphyca/android-junit4-robolectric
/**
* @param name
* @param mode
* @param factory
* @param errorHandler
* @return
* @see android.content.ContextWrapper#openOrCreateDatabase(java.lang.String,
* int, android.database.sqlite.SQLiteDatabase.CursorFactory,
* android.database.DatabaseErrorHandler)
*/
public SQLiteDatabase openOrCreateDatabase(String name,
int mode,
CursorFactory factory,
DatabaseErrorHandler errorHandler) {
return mActivity.openOrCreateDatabase(name, mode, factory, errorHandler);
}
代码示例来源:origin: enricocid/LaunchEnr
static String selectedItem(Activity activity, String[] who, int where, ArrayList<String> column) {
//create the notes db
SQLiteDatabase notesDB = activity.openOrCreateDatabase("notesDB", MODE_PRIVATE, null);
Cursor notesCursor = notesDB.rawQuery("SELECT * FROM " + who[0], null);
String selected = "";
if (notesCursor != null && notesCursor.moveToFirst()) {
while (!notesCursor.isAfterLast()) {
//get items at selected position
selected = column.get(where);
notesCursor.moveToNext();
}
notesCursor.close();
}
notesDB.close();
return selected;
}
}
代码示例来源:origin: enricocid/LaunchEnr
static ArrayList<String> initNoteElement(Activity activity, String[] who) {
//create the notes db
SQLiteDatabase notesDB = activity.openOrCreateDatabase("notesDB", MODE_PRIVATE, null);
//create a table called ? with a column called ? where notes titles will be stored
notesDB.execSQL("CREATE TABLE IF NOT EXISTS " + who[0] + "(id INTEGER PRIMARY KEY AUTOINCREMENT," + who[1] + " varchar);");
ArrayList<String> selected = new ArrayList<>();
Cursor notesDBcursor;
notesDBcursor = notesDB.rawQuery("SELECT * FROM " + who[0], null);
if (notesDBcursor != null && notesDBcursor.moveToFirst()) {
while (!notesDBcursor.isAfterLast()) {
//add items to selected field
selected.add(notesDBcursor.getString(notesDBcursor.getColumnIndex(who[1])));
notesDBcursor.moveToNext();
}
notesDBcursor.close();
}
notesDB.close();
return selected;
}
代码示例来源:origin: srbcheema1/Calculater
public int verifytoken(String orgstr) {
try {
String str = Token.lastToken(orgstr).getVal().toString();
SQLiteDatabase db = MainActivity.activity.openOrCreateDatabase("data", MODE_PRIVATE, null);
db.execSQL("create table if not exists key (key varchar,ans varchar)");
代码示例来源:origin: enricocid/LaunchEnr
@Override
public void onClick(DialogInterface dialog, int which) {
SQLiteDatabase notesDB = getActivity().openOrCreateDatabase("notesDB", MODE_PRIVATE, null);
代码示例来源:origin: enricocid/LaunchEnr
private static void deleteNote(Activity activity, int pos) {
SQLiteDatabase notesDB = activity.openOrCreateDatabase("notesDB", MODE_PRIVATE, null);
内容来源于网络,如有侵权,请联系作者删除!