Search in sources :

Example 96 with SQLException

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);
}
Also used : SQLException(android.database.SQLException) Uri(android.net.Uri)

Example 97 with SQLException

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");
}
Also used : User(com.meisolsson.githubsdk.model.User) SQLException(android.database.SQLException) IOException(java.io.IOException)

Example 98 with SQLException

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);
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) SQLException(android.database.SQLException) DatabaseUtils(android.database.DatabaseUtils) Gson(com.google.gson.Gson)

Example 99 with SQLException

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);
}
Also used : SQLException(android.database.SQLException) DatabaseUtils(android.database.DatabaseUtils) Gson(com.google.gson.Gson) CommentBean(org.qii.weiciyuan.bean.CommentBean)

Example 100 with SQLException

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);
}
Also used : SQLException(android.database.SQLException) DatabaseUtils(android.database.DatabaseUtils) Gson(com.google.gson.Gson) CommentBean(org.qii.weiciyuan.bean.CommentBean)

Aggregations

SQLException (android.database.SQLException)154 Cursor (android.database.Cursor)51 ContentValues (android.content.ContentValues)50 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)31 Uri (android.net.Uri)30 SQLiteStatement (android.database.sqlite.SQLiteStatement)13 ArrayList (java.util.ArrayList)10 DatabaseUtils (android.database.DatabaseUtils)8 Gson (com.google.gson.Gson)8 RAction (io.github.mthli.Bitocle.Database.Repo.RAction)7 Repo (io.github.mthli.Bitocle.Database.Repo.Repo)6 SQLiteOpenHelper (android.database.sqlite.SQLiteOpenHelper)5 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)5 IOException (java.io.IOException)5 BAction (io.github.mthli.Bitocle.Database.Bookmark.BAction)4 Test (org.junit.Test)4 Activity (android.app.Activity)3 ContentResolver (android.content.ContentResolver)3 Context (android.content.Context)3 LayoutInflater (android.view.LayoutInflater)3