本文整理汇总了Java中android.database.SQLException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java SQLException.printStackTrace方法的具体用法?Java SQLException.printStackTrace怎么用?Java SQLException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.database.SQLException
的用法示例。
在下文中一共展示了SQLException.printStackTrace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClick
import android.database.SQLException; //导入方法依赖的package包/类
@Override
public void onClick(View view) {
try {
// save this group to database ....
ArticlesDataSource mDbHelper = new ArticlesDataSource(getApplicationContext());
mDbHelper.createDatabase();
mDbHelper.open();
long lastInsertedId = mDbHelper.saveGroup(groupName, listOfIdsLessons);
if (lastInsertedId != -1) {
//Toast.makeText(getApplicationContext(), R.string.group_has_been_saved, Toast.LENGTH_SHORT).show();
// ... and go to activity to show it
Intent intent = new Intent(getApplicationContext(), AllArticlesListViewActivity.class);
intent.putExtra("group_id", lastInsertedId);
intent.putExtra("group_name", groupName);
intent.putExtra("status_what_show", ActivityArticlesStatusToShow.SHOW_ALL_GROUPS);
startActivity(intent);
} else {
// throw exception
}
} catch (SQLException e) {
e.printStackTrace();
}
}
示例2: addAgentInfo
import android.database.SQLException; //导入方法依赖的package包/类
public boolean addAgentInfo(AgentInfo agentInfo) {
try {
if (getSQLiteDatabase() == null) {
return false;
}
String sql = "replace into "
+ UdeskDBHelper.UdeskAgentMsg
+ "(AgentJid ,HeadUrl ,AgentNick )"
+ " values (?,?,?)";
getSQLiteDatabase().execSQL(
sql,
new Object[] { agentInfo.getAgentJid(),agentInfo.getHeadUrl(),agentInfo.getAgentNick()});
return true;
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
示例3: insert_sqlite
import android.database.SQLException; //导入方法依赖的package包/类
private long insert_sqlite() {
long start = System.currentTimeMillis();
// 在一个事物里面运行
_Database.beginTransaction();
try {
for (int i = 0; i < MAX; i++) {
String sql = "insert into dog(name) values('哈士奇')";
_Database.execSQL(sql);
}
_Database.setTransactionSuccessful();
} catch (SQLException e) {
e.printStackTrace();
} finally {
_Database.endTransaction();
}
long end = System.currentTimeMillis();
return end - start;
}
示例4: refreshDisplay
import android.database.SQLException; //导入方法依赖的package包/类
private void refreshDisplay(Context context, int type) {
try {
db.open();
if (type != 0) {
changes = db.getAllItms(type);
} else {
changes = db.getAllItms();
}
} catch (SQLException e) {
FirebaseCrash.report(e);
e.printStackTrace();
}
db.close();
if (changes != null) {
listAdapter = new changeAdapter(context, changes);
listView.setAdapter(listAdapter);
}
}
示例5: BaseDAO
import android.database.SQLException; //导入方法依赖的package包/类
public BaseDAO(final Context context) {
this.context = context;
dbHelper = DataBaseHelper.getInstance();
try {
open();
} catch (SQLException e) {
Log.e(TAG, "SQLException on openning database " + e.getMessage());
e.printStackTrace();
}
}
示例6: getTabs
import android.database.SQLException; //导入方法依赖的package包/类
public ArrayList<HashMap<String, Integer>> getTabs() {
ArrayList<HashMap<String, Integer>> hashMaps = new ArrayList<>();
String query = "SELECT * FROM " + TABS_TABLE;
Cursor cursor = getDatabase().rawQuery(query, null);
if (cursor != null && cursor.getCount() > 0) {
if (cursor.moveToFirst()) {
do {
HashMap<String, Integer> stringIntegerHashMap = new HashMap<>();
stringIntegerHashMap.put(cursor.getString(cursor.getColumnIndex(TAB_NAME)), cursor.getInt(cursor.getColumnIndex(TAB_POSITION)));
hashMaps.add(stringIntegerHashMap);
} while (cursor.moveToNext());
}
cursor.close();
return hashMaps;
} else {
String[] tabs = Common.getInstance().getResources().getStringArray(R.array.fragments_titles);
for (int i = 0; i < tabs.length; i++) {
ContentValues values = new ContentValues();
values.put(TAB_NAME, tabs[i]);
values.put(TAB_POSITION, i);
try {
getDatabase().insertOrThrow(TABS_TABLE, null, values);
} catch (SQLException e) {
e.printStackTrace();
}
}
return getTabs();
}
}
示例7: addMessageInfo
import android.database.SQLException; //导入方法依赖的package包/类
/**
* db中增加一条消息的语句
*
* @param msg
*/
public boolean addMessageInfo(MessageInfo msg) {
try {
if (getSQLiteDatabase() == null || msg == null) {
return false;
}
String sql = "replace into "
+ UdeskDBHelper.UdeskMessage
+ "(MsgID ,Time ,MsgContent,MsgType,ReadFlag,SendFlag,PlayedFlag,"
+ "Direction,LocalPath,Duration,AgentJid,created_at,updated_at,reply_user,reply_userurl)"
+ " values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
getSQLiteDatabase().execSQL(
sql,
new Object[] { msg.getMsgId(), msg.getTime(),
msg.getMsgContent(), msg.getMsgtype(),
msg.getReadFlag(), msg.getSendFlag(),
msg.getPlayflag(), msg.getDirection(),
msg.getLocalPath(), msg.getDuration() ,
msg.getmAgentJid(),msg.getCreatedTime(),
msg.getUpdateTime(),msg.getReplyUser(),
msg.getUser_avatar()
});
return true;
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
示例8: updateFolderItemsRank
import android.database.SQLException; //导入方法依赖的package包/类
@Thunk boolean updateFolderItemsRank(SQLiteDatabase db, boolean addRankColumn) {
db.beginTransaction();
try {
if (addRankColumn) {
// Insert new column for holding rank
db.execSQL("ALTER TABLE favorites ADD COLUMN rank INTEGER NOT NULL DEFAULT 0;");
}
// Get a map for folder ID to folder width
Cursor c = db.rawQuery("SELECT container, MAX(cellX) FROM favorites"
+ " WHERE container IN (SELECT _id FROM favorites WHERE itemType = ?)"
+ " GROUP BY container;",
new String[] {Integer.toString(LauncherSettings.Favorites.ITEM_TYPE_FOLDER)});
while (c.moveToNext()) {
db.execSQL("UPDATE favorites SET rank=cellX+(cellY*?) WHERE "
+ "container=? AND cellX IS NOT NULL AND cellY IS NOT NULL;",
new Object[] {c.getLong(1) + 1, c.getLong(0)});
}
c.close();
db.setTransactionSuccessful();
} catch (SQLException ex) {
// Old version remains, which means we wipe old data
ex.printStackTrace();
return false;
} finally {
db.endTransaction();
}
return true;
}
示例9: addEQValues
import android.database.SQLException; //导入方法依赖的package包/类
/**
* Saves a song's equalizer/audio effect settings to the database.
*/
public void addEQValues(int fiftyHertz,
int oneThirtyHertz,
int threeTwentyHertz,
int eightHundredHertz,
int twoKilohertz,
int fiveKilohertz,
int twelvePointFiveKilohertz,
int virtualizer,
int bassBoost,
int reverb,
int volume) {
ContentValues values = new ContentValues();
values.put(EQ_50_HZ, fiftyHertz);
values.put(EQ_130_HZ, oneThirtyHertz);
values.put(EQ_320_HZ, threeTwentyHertz);
values.put(EQ_800_HZ, eightHundredHertz);
values.put(EQ_2000_HZ, twoKilohertz);
values.put(EQ_5000_HZ, fiveKilohertz);
values.put(EQ_12500_HZ, twelvePointFiveKilohertz);
values.put(VIRTUALIZER, virtualizer);
values.put(BASS_BOOST, bassBoost);
values.put(REVERB, reverb);
values.put(VOLUME, volume);
try {
getDatabase().insertOrThrow(EQUALIZER_TABLE, null, values);
} catch (SQLException e) {
e.printStackTrace();
}
}
示例10: onCreate
import android.database.SQLException; //导入方法依赖的package包/类
@Override
public void onCreate(SQLiteDatabase db) {
try
{
db.execSQL(DATABASE_CREATE);
}
catch(SQLException e)
{
e.printStackTrace();
}
}
示例11: onCreate
import android.database.SQLException; //导入方法依赖的package包/类
@Override
public void onCreate(SQLiteDatabase db)
{
try {
db.execSQL(DATABASE_CREATION);
}
catch (SQLException e) {
e.printStackTrace();
}
}
示例12: onCreate
import android.database.SQLException; //导入方法依赖的package包/类
public void onCreate(SQLiteDatabase db) {
try {
db.execSQL(CREATE_MAINTABLE_HIDES);
} catch (SQLException e) {
FirebaseCrash.report(e);
e.printStackTrace();
}
}
示例13: onCreate
import android.database.SQLException; //导入方法依赖的package包/类
public void onCreate(SQLiteDatabase db) {
try {
db.execSQL(userDBAdapter.CREATE_MAINTABLE_USER);
} catch (SQLException e) {
FirebaseCrash.report(e);
e.printStackTrace();
}
}
示例14: onCreate
import android.database.SQLException; //导入方法依赖的package包/类
public void onCreate(SQLiteDatabase db) {
try {
db.execSQL(changesDBAdapter.CREATE_MAINTABLE_CHANGES);
} catch (SQLException e) {
FirebaseCrash.report(e);
e.printStackTrace();
}
}
示例15: onCreate
import android.database.SQLException; //导入方法依赖的package包/类
public void onCreate(SQLiteDatabase db) {
try {
db.execSQL(CREATE_MAINTABLE_CATS);
} catch (SQLException e) {
FirebaseCrash.report(e);
e.printStackTrace();
}
}