use of android.database.SQLException in project mobile-android by photo.
the class UploadsProvider method insert.
@Override
public Uri insert(Uri uri, ContentValues values) {
long rowId = mDb.insert(PHOTOS_TABLE, "contact", values);
if (rowId > 0) {
Uri insertedUri = ContentUris.withAppendedId(CONTENT_URI, rowId);
getContext().getContentResolver().notifyChange(insertedUri, null);
return insertedUri;
}
throw new SQLException("Failed to insert row into " + uri);
}
use of android.database.SQLException in project PocketHub by pockethub.
the class SyncCampaign method run.
@Override
public void run() {
List<User> orgs;
try {
orgs = cache.requestAndStore(persistedOrgs);
syncResult.stats.numUpdates++;
} catch (IOException | SQLException e) {
syncResult.stats.numIoExceptions++;
Log.d(TAG, "Exception requesting users and orgs", e);
return;
}
Log.d(TAG, "Syncing " + orgs.size() + " users and orgs");
for (User org : orgs) {
if (cancelled) {
return;
}
Log.d(TAG, "Syncing repos for " + org.login());
try {
cache.requestAndStore(repos.under(org));
syncResult.stats.numUpdates++;
} catch (IOException | SQLException e) {
syncResult.stats.numIoExceptions++;
Log.d(TAG, "Exception requesting repositories", e);
}
}
Log.d(TAG, "Sync campaign finished");
}
use of android.database.SQLException in project weiciyuan by qii.
the class FriendsTimeLineDBTask method addHomeLineMsg.
private static void addHomeLineMsg(MessageListBean list, String accountId) {
if (list == null || list.getSize() == 0) {
return;
}
Gson gson = new Gson();
List<MessageBean> msgList = list.getItemList();
DatabaseUtils.InsertHelper ih = new DatabaseUtils.InsertHelper(getWsd(), HomeTable.HomeDataTable.TABLE_NAME);
final int mblogidColumn = ih.getColumnIndex(HomeTable.HomeDataTable.MBLOGID);
final int accountidColumn = ih.getColumnIndex(HomeTable.HomeDataTable.ACCOUNTID);
final int jsondataColumn = ih.getColumnIndex(HomeTable.HomeDataTable.JSONDATA);
try {
getWsd().beginTransaction();
for (int i = 0; i < msgList.size(); i++) {
MessageBean msg = msgList.get(i);
ih.prepareForInsert();
if (msg != null) {
ih.bind(mblogidColumn, msg.getId());
ih.bind(accountidColumn, accountId);
String json = gson.toJson(msg);
ih.bind(jsondataColumn, json);
} else {
ih.bind(mblogidColumn, "-1");
ih.bind(accountidColumn, accountId);
ih.bind(jsondataColumn, "");
}
ih.execute();
}
getWsd().setTransactionSuccessful();
} catch (SQLException e) {
} finally {
getWsd().endTransaction();
ih.close();
}
reduceHomeTable(accountId);
}
use of android.database.SQLException in project weiciyuan by qii.
the class CommentByMeTimeLineDBTask method addCommentLineMsg.
public static void addCommentLineMsg(CommentListBean list, String accountId) {
Gson gson = new Gson();
List<CommentBean> msgList = list.getItemList();
DatabaseUtils.InsertHelper ih = new DatabaseUtils.InsertHelper(getWsd(), CommentByMeTable.CommentByMeDataTable.TABLE_NAME);
final int mblogidColumn = ih.getColumnIndex(CommentByMeTable.CommentByMeDataTable.MBLOGID);
final int accountidColumn = ih.getColumnIndex(CommentByMeTable.CommentByMeDataTable.ACCOUNTID);
final int jsondataColumn = ih.getColumnIndex(CommentByMeTable.CommentByMeDataTable.JSONDATA);
try {
getWsd().beginTransaction();
for (CommentBean msg : msgList) {
ih.prepareForInsert();
if (msg != null) {
ih.bind(mblogidColumn, msg.getId());
ih.bind(accountidColumn, accountId);
String json = gson.toJson(msg);
ih.bind(jsondataColumn, json);
} else {
ih.bind(mblogidColumn, "-1");
ih.bind(accountidColumn, accountId);
ih.bind(jsondataColumn, "");
}
ih.execute();
}
getWsd().setTransactionSuccessful();
} catch (SQLException e) {
} finally {
getWsd().endTransaction();
ih.close();
}
reduceCommentTable(accountId);
}
use of android.database.SQLException in project weiciyuan by qii.
the class CommentToMeTimeLineDBTask method addCommentLineMsg.
public static void addCommentLineMsg(CommentListBean list, String accountId) {
Gson gson = new Gson();
List<CommentBean> msgList = list.getItemList();
DatabaseUtils.InsertHelper ih = new DatabaseUtils.InsertHelper(getWsd(), CommentsTable.CommentsDataTable.TABLE_NAME);
final int mblogidColumn = ih.getColumnIndex(CommentsTable.CommentsDataTable.MBLOGID);
final int accountidColumn = ih.getColumnIndex(CommentsTable.CommentsDataTable.ACCOUNTID);
final int jsondataColumn = ih.getColumnIndex(CommentsTable.CommentsDataTable.JSONDATA);
try {
getWsd().beginTransaction();
for (CommentBean msg : msgList) {
ih.prepareForInsert();
if (msg != null) {
ih.bind(mblogidColumn, msg.getId());
ih.bind(accountidColumn, accountId);
String json = gson.toJson(msg);
ih.bind(jsondataColumn, json);
} else {
ih.bind(mblogidColumn, "-1");
ih.bind(accountidColumn, accountId);
ih.bind(jsondataColumn, "");
}
ih.execute();
}
getWsd().setTransactionSuccessful();
} catch (SQLException e) {
} finally {
getWsd().endTransaction();
ih.close();
}
reduceCommentTable(accountId);
}
Aggregations