Java Code Examples for android.database.SQLException
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/persistence/provider/.
Source file: AbstractCollectionProvider.java

@Override public Uri insert(Uri url,ContentValues values,SQLiteDatabase db){ addDefaultValues(values); long rowID=db.insert(getTableName(),getElementsMap().get(primaryKey),values); if (rowID > 0) { Uri uri=ContentUris.withAppendedId(contentUri,rowID); notifyOnChange(uri); return uri; } throw new SQLException("Failed to insert row into " + url); }
Example 2
From project android_packages_apps_FileManager, under directory /src/org/openintents/filemanager/.
Source file: BookmarksProvider.java

@Override public Uri insert(Uri uri,ContentValues values){ long rowID=db.insert(TB_NAME,"",values); if (rowID > 0) { Uri _uri=ContentUris.withAppendedId(CONTENT_URI,rowID); getContext().getContentResolver().notifyChange(_uri,null); return _uri; } throw new SQLException("Failed to insert row into " + uri); }
Example 3
From project cw-advandroid, under directory /ContentProvider/ConstantsPlus/src/com/commonsware/android/constants/.
Source file: Provider.java

@Override public Uri insert(Uri url,ContentValues initialValues){ long rowID=db.getWritableDatabase().insert(TABLE,Constants.TITLE,initialValues); if (rowID > 0) { Uri uri=ContentUris.withAppendedId(Provider.Constants.CONTENT_URI,rowID); getContext().getContentResolver().notifyChange(uri,null); return (uri); } throw new SQLException("Failed to insert row into " + url); }
Example 4
From project cw-omnibus, under directory /ContentProvider/ConstantsPlus/src/com/commonsware/android/constants/.
Source file: Provider.java

@Override public Uri insert(Uri url,ContentValues initialValues){ long rowID=db.getWritableDatabase().insert(TABLE,Constants.TITLE,initialValues); if (rowID > 0) { Uri uri=ContentUris.withAppendedId(Provider.Constants.CONTENT_URI,rowID); getContext().getContentResolver().notifyChange(uri,null); return (uri); } throw new SQLException("Failed to insert row into " + url); }
Example 5
From project DeliciousDroid, under directory /src/com/deliciousdroid/providers/.
Source file: BookmarkContentProvider.java

private Uri insertBookmark(Uri uri,ContentValues values){ db=dbHelper.getWritableDatabase(); long rowId=db.insert(BOOKMARK_TABLE_NAME,"",values); if (rowId > 0) { Uri rowUri=ContentUris.appendId(BookmarkContent.Bookmark.CONTENT_URI.buildUpon(),rowId).build(); getContext().getContentResolver().notifyChange(rowUri,null); return rowUri; } throw new SQLException("Failed to insert row into " + uri); }
Example 6
From project filemanager, under directory /FileManager/src/org/openintents/filemanager/bookmarks/.
Source file: BookmarksProvider.java

@Override public Uri insert(Uri uri,ContentValues values){ long rowID=db.insert(TB_NAME,"",values); if (rowID > 0) { Uri _uri=ContentUris.withAppendedId(CONTENT_URI,rowID); getContext().getContentResolver().notifyChange(_uri,null); return _uri; } throw new SQLException("Failed to insert row into " + uri); }
Example 7
From project Locast-Android, under directory /src/edu/mit/mobile/android/content/.
Source file: GenericDBHelper.java

@Override public Uri insertDir(SQLiteDatabase db,ContentProvider provider,Uri uri,ContentValues values){ final long id=db.insert(mTable,null,values); if (id != -1) { return ContentUris.withAppendedId(mContentUri,id); } else { throw new SQLException("error inserting into " + mTable); } }
Example 8
From project NFC-Contact-Exchanger, under directory /src/com/tonchidot/nfc_contact_exchanger/.
Source file: ContactsProvider.java

@Override public Uri insert(Uri uri,ContentValues values){ long rowId=db.insert(CONTACTS_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); }
Example 9
From project OpenBike, under directory /src/fr/openbike/android/database/.
Source file: OpenBikeDBAdapter.java

public Cursor getStation(int id,String[] columns) throws SQLException { Cursor cursor=mDb.query(true,STATIONS_TABLE,columns,BaseColumns._ID + " = ? AND " + KEY_NETWORK+ " = ?",new String[]{String.valueOf(id),String.valueOf(mPreferences.getInt(AbstractPreferencesActivity.NETWORK_PREFERENCE,AbstractPreferencesActivity.NO_NETWORK))},null,null,null,null); if ((cursor.getCount() == 0) || !cursor.moveToFirst()) { throw new SQLException("No Station found with ID " + id); } return cursor; }
Example 10
From project packages_apps_ROMControl, under directory /src/com/aokp/romcontrol/vibrations/.
Source file: VibrationsProvider.java

@Override public Uri insert(Uri uri,ContentValues values){ long rowID=vibrationsDB.insert(DATABASE_TABLE,"",values); if (rowID > 0) { Uri _uri=ContentUris.withAppendedId(CONTENT_URI,rowID); getContext().getContentResolver().notifyChange(_uri,null); return _uri; } throw new SQLException("Failed to insert row into " + uri); }
Example 11
From project PinDroid, under directory /src/com/pindroid/providers/.
Source file: BookmarkContentProvider.java

private Uri insertBookmark(Uri uri,ContentValues values){ db=dbHelper.getWritableDatabase(); long rowId=db.insert(BOOKMARK_TABLE_NAME,"",values); if (rowId > 0) { Uri rowUri=ContentUris.appendId(BookmarkContent.Bookmark.CONTENT_URI.buildUpon(),rowId).build(); getContext().getContentResolver().notifyChange(rowUri,null,true); return rowUri; } throw new SQLException("Failed to insert row into " + uri); }
Example 12
From project platform_packages_providers_contactsprovider, under directory /src/com/android/providers/contacts/.
Source file: LegacyApiSupport.java

private void updateSetting(SQLiteDatabase db,String accountName,String accountType,ContentValues values){ final String key=values.getAsString(android.provider.Contacts.Settings.KEY); if (accountName == null || accountType == null) { db.delete(LegacyTables.SETTINGS,"_sync_account IS NULL AND key=?",new String[]{key}); } else { db.delete(LegacyTables.SETTINGS,"_sync_account=? AND _sync_account_type=? AND key=?",new String[]{accountName,accountType,key}); } long rowId=db.insert(LegacyTables.SETTINGS,android.provider.Contacts.Settings.KEY,values); if (rowId < 0) { throw new SQLException("error updating settings with " + values); } }
Example 13
From project propoid, under directory /propoid-db/src/main/java/propoid/db/service/.
Source file: RepositorySuggest.java

@Override public long getLong(int column){ if (column == 0) { return Row.getID(getPropoid()); } throw new SQLException(); }
Example 14
From project ActionBarSherlock, under directory /samples/fragments/src/com/actionbarsherlock/sample/fragments/.
Source file: LoaderThrottleSupport.java

/** * Handler inserting new data. */ @Override public Uri insert(Uri uri,ContentValues initialValues){ if (mUriMatcher.match(uri) != MAIN) { throw new IllegalArgumentException("Unknown URI " + uri); } ContentValues values; if (initialValues != null) { values=new ContentValues(initialValues); } else { values=new ContentValues(); } if (values.containsKey(MainTable.COLUMN_NAME_DATA) == false) { values.put(MainTable.COLUMN_NAME_DATA,""); } SQLiteDatabase db=mOpenHelper.getWritableDatabase(); long rowId=db.insert(MainTable.TABLE_NAME,null,values); if (rowId > 0) { Uri noteUri=ContentUris.withAppendedId(MainTable.CONTENT_ID_URI_BASE,rowId); getContext().getContentResolver().notifyChange(noteUri,null); return noteUri; } throw new SQLException("Failed to insert row into " + uri); }
Example 15
From project android-context, under directory /src/edu/fsu/cs/contextprovider/.
Source file: ContextProvider.java

@Override public Uri insert(Uri url,ContentValues initialValues){ long rowID; ContentValues values; if (initialValues != null) { values=new ContentValues(initialValues); } else { values=new ContentValues(); } if (!isCollectionUri(url)) { throw new IllegalArgumentException("Unknown URL " + url); } for ( String colName : getRequiredColumns()) { if (values.containsKey(colName) == false) { throw new IllegalArgumentException("Missing column: " + colName); } } populateDefaultValues(values); rowID=db.insert(getTableName(),getNullColumnHack(),values); if (rowID > 0) { Uri uri=ContentUris.withAppendedId(getContentUri(),rowID); getContext().getContentResolver().notifyChange(uri,null); return uri; } throw new SQLException("Failed to insert row into " + url); }
Example 16
From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/provider/.
Source file: BooksProvider.java

public Uri insert(Uri uri,ContentValues initialValues){ ContentValues values; if (initialValues != null) { values=new ContentValues(initialValues); values.put(BooksStore.Book.SORT_TITLE,keyFor(values.getAsString(BooksStore.Book.TITLE))); } else { values=new ContentValues(); } if (URI_MATCHER.match(uri) != BOOKS) { throw new IllegalArgumentException("Unknown URI " + uri); } SQLiteDatabase db=mOpenHelper.getWritableDatabase(); final long rowId=db.insert("books",BooksStore.Book.TITLE,values); if (rowId > 0) { Uri insertUri=ContentUris.withAppendedId(BooksStore.Book.CONTENT_URI,rowId); getContext().getContentResolver().notifyChange(uri,null); return insertUri; } throw new SQLException("Failed to insert row into " + uri); }
Example 17
From project Android_1, under directory /PropagatedIntents/src/com/example/android/notepad/.
Source file: NotePadProvider.java

@Override public Uri insert(Uri uri,ContentValues initialValues){ if (sUriMatcher.match(uri) != NOTES) { throw new IllegalArgumentException("Unknown URI " + uri); } ContentValues values; if (initialValues != null) { values=new ContentValues(initialValues); } else { values=new ContentValues(); } Long now=Long.valueOf(System.currentTimeMillis()); if (values.containsKey(NotePad.Notes.CREATED_DATE) == false) { values.put(NotePad.Notes.CREATED_DATE,now); } if (values.containsKey(NotePad.Notes.MODIFIED_DATE) == false) { values.put(NotePad.Notes.MODIFIED_DATE,now); } if (values.containsKey(NotePad.Notes.TITLE) == false) { Resources r=Resources.getSystem(); values.put(NotePad.Notes.TITLE,r.getString(android.R.string.untitled)); } if (values.containsKey(NotePad.Notes.NOTE) == false) { values.put(NotePad.Notes.NOTE,""); } SQLiteDatabase db=mOpenHelper.getWritableDatabase(); long rowId=db.insert(NOTES_TABLE_NAME,Notes.NOTE,values); if (rowId > 0) { Uri noteUri=ContentUris.withAppendedId(NotePad.Notes.CONTENT_URI,rowId); getContext().getContentResolver().notifyChange(noteUri,null); return noteUri; } throw new SQLException("Failed to insert row into " + uri); }
Example 18
From project android_packages_apps_cmparts, under directory /src/com/cyanogenmod/cmparts/provider/.
Source file: SettingsProvider.java

@Override public Uri insert(Uri uri,ContentValues initialValues){ if (URI_MATCHER.match(uri) != SETTINGS) { throw new IllegalArgumentException("Cannot insert into URI: " + uri); } ContentValues values=(initialValues != null) ? new ContentValues(initialValues) : new ContentValues(); for ( String colName : Constants.getRequiredColumns()) { if (values.containsKey(colName) == false) { throw new IllegalArgumentException("Missing column: " + colName); } } SQLiteDatabase db=mOpenHelper.getWritableDatabase(); long rowId=db.insert(TABLE_NAME,"",values); if (rowId < 0) { throw new SQLException("Failed to insert row into: " + uri); } Uri noteUri=ContentUris.withAppendedId(CONTENT_URI,rowId); getContext().getContentResolver().notifyChange(noteUri,null); return noteUri; }
Example 19
From project android_packages_apps_Gallery3D, under directory /src/com/cooliris/picasa/.
Source file: TableContentProvider.java

@Override public Uri insert(Uri uri,ContentValues values){ int match=mUriMatcher.match(uri); Mapping mapping=match != UriMatcher.NO_MATCH ? mMappings.get(match) : null; if (mapping == null || mapping.hasId) { throw new IllegalArgumentException("Invalid URI: " + uri); } String tableName=mapping.table.getTableName(); long rowId=mDatabase.getWritableDatabase().insert(tableName,NULL_COLUMN_HACK,values); if (rowId > 0) { notifyChange(uri); return Uri.withAppendedPath(uri,Long.toString(rowId)); } else { throw new SQLException("Failed to insert row at: " + uri); } }
Example 20
From project android_packages_apps_SalvageParts, under directory /src/com/salvagemod/salvageparts/provider/.
Source file: SettingsProvider.java

@Override public Uri insert(Uri uri,ContentValues initialValues){ if (URI_MATCHER.match(uri) != SETTINGS) { throw new IllegalArgumentException("Cannot insert into URI: " + uri); } ContentValues values=(initialValues != null) ? new ContentValues(initialValues) : new ContentValues(); for ( String colName : Constants.getRequiredColumns()) { if (values.containsKey(colName) == false) { throw new IllegalArgumentException("Missing column: " + colName); } } SQLiteDatabase db=mOpenHelper.getWritableDatabase(); long rowId=db.insert(TABLE_NAME,"",values); if (rowId < 0) { throw new SQLException("Failed to insert row into: " + uri); } Uri noteUri=ContentUris.withAppendedId(CONTENT_URI,rowId); getContext().getContentResolver().notifyChange(noteUri,null); return noteUri; }
Example 21
/** * Convenience method for querying the database for a single integer result. * @param query The raw SQL query to use. * @return The integer result of the query. */ public long queryScalar(String query) throws SQLException { Cursor cursor=null; long scalar; try { cursor=mDatabase.rawQuery(query,null); if (!cursor.moveToFirst()) { throw new SQLException("No result for query: " + query); } scalar=cursor.getLong(0); } finally { if (cursor != null) { cursor.close(); } } return scalar; }
Example 22
From project apps-for-android, under directory /WikiNotes/src/com/google/android/wikinotes/db/.
Source file: WikiNotesProvider.java

/** * For a URL and a list of initial values, insert a row using those values into the database. */ @Override public Uri insert(Uri uri,ContentValues initialValues){ long rowID; ContentValues values; if (initialValues != null) { values=new ContentValues(initialValues); } else { values=new ContentValues(); } if (URI_MATCHER.match(uri) != NOTE_NAME) { throw new IllegalArgumentException("Unknown URL " + uri); } Long now=Long.valueOf(System.currentTimeMillis()); if (values.containsKey(WikiNote.Notes.CREATED_DATE) == false) { values.put(WikiNote.Notes.CREATED_DATE,now); } if (values.containsKey(WikiNote.Notes.MODIFIED_DATE) == false) { values.put(WikiNote.Notes.MODIFIED_DATE,now); } if (values.containsKey(WikiNote.Notes.TITLE) == false) { values.put(WikiNote.Notes.TITLE,uri.getLastPathSegment()); } if (values.containsKey(WikiNote.Notes.BODY) == false) { values.put(WikiNote.Notes.BODY,""); } SQLiteDatabase db=dbHelper.getWritableDatabase(); rowID=db.insert("wikinotes","body",values); if (rowID > 0) { Uri newUri=Uri.withAppendedPath(WikiNote.Notes.ALL_NOTES_URI,uri.getLastPathSegment()); getContext().getContentResolver().notifyChange(newUri,null); return newUri; } throw new SQLException("Failed to insert row into " + uri); }
Example 23
From project CineShowTime-Android, under directory /Libraries/CineShowTime/src/com/binomed/showtime/android/adapter/db/.
Source file: CineShowtimeDbAdapter.java

private void chekDbAvailable(){ do { if (isDbLockedByCurrentThread() || isDbLockedByOtherThreads()) { try { if (Log.isLoggable(TAG,Log.DEBUG)) { Log.d(TAG,"DbBusy wait for availabality"); } Thread.sleep(100); } catch ( InterruptedException e) { } } } while (isOpen() && (isDbLockedByCurrentThread() || isDbLockedByOtherThreads())); if (!isOpen()) { throw new SQLException("DBClosed"); } if (Log.isLoggable(TAG,Log.DEBUG)) { Log.d(TAG,"DbAvailable"); } }
Example 24
From project COSsettings, under directory /src/com/cyanogenmod/cmparts/provider/.
Source file: SettingsProvider.java

@Override public Uri insert(Uri uri,ContentValues initialValues){ if (URI_MATCHER.match(uri) != SETTINGS) { throw new IllegalArgumentException("Cannot insert into URI: " + uri); } ContentValues values=(initialValues != null) ? new ContentValues(initialValues) : new ContentValues(); for ( String colName : Constants.getRequiredColumns()) { if (values.containsKey(colName) == false) { throw new IllegalArgumentException("Missing column: " + colName); } } SQLiteDatabase db=mOpenHelper.getWritableDatabase(); long rowId=db.insert(TABLE_NAME,"",values); if (rowId < 0) { throw new SQLException("Failed to insert row into: " + uri); } Uri noteUri=ContentUris.withAppendedId(CONTENT_URI,rowId); getContext().getContentResolver().notifyChange(noteUri,null); return noteUri; }
Example 25
From project Diktofon, under directory /app/src/kaljurand_at_gmail_dot_com/diktofon/provider/.
Source file: SpeakersContentProvider.java

@Override public Uri insert(Uri uri,ContentValues initialValues){ ContentValues values; if (initialValues != null) { values=new ContentValues(initialValues); } else { values=new ContentValues(); } SQLiteDatabase db=dbHelper.getWritableDatabase(); long rowId=0; Uri returnUri=null; switch (sUriMatcher.match(uri)) { case SPEAKERS: rowId=db.insert(SPEAKERS_TABLE_NAME,Speaker.Columns.DESC,values); if (rowId <= 0) { throw new SQLException("Failed to insert row into " + uri); } returnUri=ContentUris.withAppendedId(Speaker.Columns.CONTENT_URI,rowId); getContext().getContentResolver().notifyChange(returnUri,null); return returnUri; case TSPEAKERS: rowId=db.insert(TSPEAKERS_TABLE_NAME,TSpeaker.Columns.SPEAKER_ID,values); if (rowId <= 0) { throw new SQLException("Failed to insert row into " + uri); } returnUri=Uri.withAppendedPath(TSpeaker.Columns.CONTENT_URI,"BUG: this should be tspeaker ID"); getContext().getContentResolver().notifyChange(returnUri,null); return returnUri; default : throw new IllegalArgumentException("Unknown URI " + uri); } }
Example 26
From project dmix, under directory /MPDroid/src/com/namelessdev/mpdroid/providers/.
Source file: ServerListProvider.java

@Override public Uri insert(Uri uri,ContentValues initialValues){ if (sUriMatcher.match(uri) != SERVERS) throw new IllegalArgumentException("Unknown URI " + uri); ContentValues values=initialValues != null ? new ContentValues(initialValues) : new ContentValues(); Long now=Long.valueOf(System.currentTimeMillis()); if (!values.containsKey(ServerColumns.NAME)) values.put(ServerColumns.NAME,Resources.getSystem().getString(android.R.string.untitled) + now.toString()); if (!values.containsKey(ServerColumns.HOST)) values.put(ServerColumns.HOST,"0.0.0.0"); if (!values.containsKey(ServerColumns.PORT)) values.put(ServerColumns.PORT,"6600"); if (!values.containsKey(ServerColumns.STREAMING_PORT)) values.put(ServerColumns.STREAMING_PORT,"8000"); if (!values.containsKey(ServerColumns.STREAMING_URL)) values.put(ServerColumns.STREAMING_URL,""); if (!values.containsKey(ServerColumns.PASSWORD)) values.put(ServerColumns.PASSWORD,""); SQLiteDatabase db=mOpenHelper.getWritableDatabase(); long rowId=db.insert(SERVERS_TABLE_NAME,"server",values); if (rowId > 0) { Uri noteUri=ContentUris.withAppendedId(ServerColumns.CONTENT_URI,rowId); getContext().getContentResolver().notifyChange(noteUri,null); return noteUri; } throw new SQLException("Failed to insert row into " + uri); }
Example 27
From project ElectricSleep, under directory /src/com/androsz/electricsleepbeta/alarmclock/.
Source file: AlarmProvider.java

@Override public Uri insert(final Uri url,final ContentValues initialValues){ if (sURLMatcher.match(url) != ALARMS) { throw new IllegalArgumentException("Cannot insert into URL: " + url); } final ContentValues values=new ContentValues(initialValues); final SQLiteDatabase db=mOpenHelper.getWritableDatabase(); final long rowId=db.insert("alarms",Alarm.Columns.MESSAGE,values); if (rowId < 0) { throw new SQLException("Failed to insert row into " + url); } if (Log.LOGV) { Log.v("Added alarm rowId = " + rowId); } final Uri newUrl=ContentUris.withAppendedId(Alarm.Columns.CONTENT_URI,rowId); getContext().getContentResolver().notifyChange(newUrl,null); return newUrl; }
Example 28
From project examples_2, under directory /ContentProvider/ContentProvider/src/com/inazaruk/contentprovider/.
Source file: PreferenceSpyProvider.java

@Override public Uri insert(Uri uri,ContentValues initialValues){ if (sUriMatcher.match(uri) != PREFERENCES_TABLE) { throw new IllegalArgumentException("Unknown URI " + uri); } ContentValues values; if (initialValues != null) { values=new ContentValues(initialValues); } else { values=new ContentValues(); } if (values.containsKey(Preferences.REMOTE_LAST_MODIFIED_TIME) == false) { values.put(Preferences.REMOTE_LAST_MODIFIED_TIME,0L); } if (values.containsKey(Preferences.REMOTE_PACKAGE) == false) { throw new SQLException("Failed to insert row into " + uri + ". "+ "No "+ Preferences.REMOTE_PACKAGE+ " was not specified."); } if (values.containsKey(Preferences.REMOTE_PREF_NAME) == false) { throw new SQLException("Failed to insert row into " + uri + ". "+ "No "+ Preferences.REMOTE_PREF_NAME+ " was not specified."); } if (values.containsKey(Preferences.LOCAL_PREF_NAME) == false) { throw new SQLException("Failed to insert row into " + uri + ". "+ "No "+ Preferences.LOCAL_PREF_NAME+ " was not specified."); } SQLiteDatabase db=mOpenHelper.getWritableDatabase(); long rowId=db.insert(Preferences.TABLE_NAME,null,values); if (rowId > 0) { Uri noteUri=ContentUris.withAppendedId(Preferences.CONTENT_URI,rowId); getContext().getContentResolver().notifyChange(noteUri,null); return noteUri; } throw new SQLException("Failed to insert row into " + uri); }
Example 29
From project finch, under directory /libs/JakeWharton-ActionBarSherlock-2eabf25/samples/fragments/src/com/actionbarsherlock/sample/fragments/.
Source file: LoaderThrottleSupport.java

/** * Handler inserting new data. */ @Override public Uri insert(Uri uri,ContentValues initialValues){ if (mUriMatcher.match(uri) != MAIN) { throw new IllegalArgumentException("Unknown URI " + uri); } ContentValues values; if (initialValues != null) { values=new ContentValues(initialValues); } else { values=new ContentValues(); } if (values.containsKey(MainTable.COLUMN_NAME_DATA) == false) { values.put(MainTable.COLUMN_NAME_DATA,""); } SQLiteDatabase db=mOpenHelper.getWritableDatabase(); long rowId=db.insert(MainTable.TABLE_NAME,null,values); if (rowId > 0) { Uri noteUri=ContentUris.withAppendedId(MainTable.CONTENT_ID_URI_BASE,rowId); getContext().getContentResolver().notifyChange(noteUri,null); return noteUri; } throw new SQLException("Failed to insert row into " + uri); }
Example 30
From project gmarks-android, under directory /src/main/java/org/thomnichols/android/gmarks/.
Source file: GmarksProvider.java

@Override public Uri insert(Uri uri,ContentValues initialValues){ if (sUriMatcher.match(uri) != BOOKMARKS_URI) { throw new IllegalArgumentException("Unknown URI " + uri); } ContentValues values; if (initialValues != null) { values=new ContentValues(initialValues); } else { values=new ContentValues(); } Long now=Long.valueOf(System.currentTimeMillis()); if (values.containsKey(Bookmark.Columns.CREATED_DATE) == false) { values.put(Bookmark.Columns.CREATED_DATE,now); } if (values.containsKey(Bookmark.Columns.MODIFIED_DATE) == false) { values.put(Bookmark.Columns.MODIFIED_DATE,now); } if (values.containsKey(Bookmark.Columns.TITLE) == false) { Resources r=Resources.getSystem(); values.put(Bookmark.Columns.TITLE,r.getString(android.R.string.untitled)); } if (values.containsKey(Bookmark.Columns.DESCRIPTION) == false) { values.put(Bookmark.Columns.DESCRIPTION,""); } SQLiteDatabase db=dbHelper.getWritableDatabase(); long rowId=db.insert(BOOKMARKS_TABLE_NAME,"",values); if (rowId > 0) { Uri noteUri=ContentUris.withAppendedId(Bookmark.CONTENT_URI,rowId); getContext().getContentResolver().notifyChange(noteUri,null); return noteUri; } throw new SQLException("Failed to insert row into " + uri); }
Example 31
From project HapiPodcastJ, under directory /src/info/xuluan/podcast/provider/.
Source file: SubscriptionColumns.java

public static ContentValues checkValues(ContentValues values,Uri uri){ if (values.containsKey(URL) == false) { throw new SQLException("Fail to insert row because URL is needed " + uri); } if (values.containsKey(LINK) == false) { values.put(LINK,""); } if (values.containsKey(TITLE) == false) { values.put(TITLE,"unknow"); } if (values.containsKey(DESCRIPTION) == false) { values.put(DESCRIPTION,""); } if (values.containsKey(LAST_UPDATED) == false) { values.put(LAST_UPDATED,0); } if (values.containsKey(LAST_ITEM_UPDATED) == false) { values.put(LAST_ITEM_UPDATED,0); } if (values.containsKey(FAIL_COUNT) == false) { values.put(FAIL_COUNT,0); } if (values.containsKey(AUTO_DOWNLOAD) == false) { values.put(AUTO_DOWNLOAD,0); } if (values.containsKey(PLAYLIST_ID) == false) { values.put(PLAYLIST_ID,-1); } return values; }
Example 32
From project hecl, under directory /android/src/org/hecl/android/.
Source file: ScriptProvider.java

@Override public Uri insert(Uri url,ContentValues initialValues){ long rowID; ContentValues values; if (initialValues != null) { values=new ContentValues(initialValues); } else { values=new ContentValues(); } if (URL_MATCHER.match(url) != SCRIPTS) { throw new IllegalArgumentException("Unknown URL " + url); } Long now=Long.valueOf(System.currentTimeMillis()); Resources r=Resources.getSystem(); if (values.containsKey(CREATED_DATE) == false) { values.put(CREATED_DATE,now); } if (values.containsKey(MODIFIED_DATE) == false) { values.put(MODIFIED_DATE,now); } if (values.containsKey(TITLE) == false) { values.put(TITLE,""); } if (values.containsKey(SCRIPT) == false) { values.put(SCRIPT,""); } rowID=db.insert("scripts","script",values); if (rowID > 0) { Uri uri=ContentUris.withAppendedId(CONTENT_URI,rowID); getContext().getContentResolver().notifyChange(uri,null); return uri; } throw new SQLException("Failed to insert row into " + url); }
Example 33
From project hsDroid, under directory /src/de/nware/app/hsDroid/provider/.
Source file: onlineService2Provider.java

@Override public Uri insert(Uri uri,ContentValues initialValues){ if (mUriMatcher.match(uri) != EXAMS) { throw new IllegalArgumentException("Unbekannte URI " + uri); } ContentValues contentValues; if (initialValues != null) { contentValues=new ContentValues(initialValues); } else { contentValues=new ContentValues(); } if (mOpenHelper == null) { Log.d(TAG,"mOpenHelper NULL"); } SQLiteDatabase db=mOpenHelper.getWritableDatabase(); long rowID=db.insert(mOpenHelper.getTableName(),ExamsCol.EXAMNAME,contentValues); if (rowID > 0) { Uri examsUri=ContentUris.withAppendedId(ExamsCol.CONTENT_URI,rowID); getContext().getContentResolver().notifyChange(examsUri,null); return examsUri; } throw new SQLException("Konnte row nicht zu " + uri + " hinzuf?gen"); }
Example 34
From project K6nele, under directory /app/src/ee/ioc/phon/android/speak/provider/.
Source file: AppsContentProvider.java

@Override public Uri insert(Uri uri,ContentValues initialValues){ ContentValues values; if (initialValues != null) { values=new ContentValues(initialValues); } else { values=new ContentValues(); } SQLiteDatabase db=dbHelper.getWritableDatabase(); long rowId=0; Uri returnUri=null; switch (sUriMatcher.match(uri)) { case APPS: rowId=db.insert(APPS_TABLE_NAME,App.Columns.FNAME,values); if (rowId <= 0) { throw new SQLException("Failed to insert row into " + uri); } returnUri=ContentUris.withAppendedId(App.Columns.CONTENT_URI,rowId); getContext().getContentResolver().notifyChange(returnUri,null); return returnUri; case GRAMMARS: rowId=db.insert(GRAMMARS_TABLE_NAME,Grammar.Columns.DESC,values); if (rowId <= 0) { throw new SQLException("Failed to insert row into " + uri); } returnUri=ContentUris.withAppendedId(Grammar.Columns.CONTENT_URI,rowId); getContext().getContentResolver().notifyChange(returnUri,null); return returnUri; case SERVERS: rowId=db.insert(SERVERS_TABLE_NAME,Server.Columns.URL,values); if (rowId <= 0) { throw new SQLException("Failed to insert row into " + uri); } returnUri=ContentUris.withAppendedId(Server.Columns.CONTENT_URI,rowId); getContext().getContentResolver().notifyChange(returnUri,null); return returnUri; default : throw new IllegalArgumentException("Unknown URI " + uri); } }
Example 35
From project maven-android-plugin-samples, under directory /support4demos/src/com/example/android/supportv4/app/.
Source file: LoaderThrottleSupport.java

/** * Handler inserting new data. */ @Override public Uri insert(Uri uri,ContentValues initialValues){ if (mUriMatcher.match(uri) != MAIN) { throw new IllegalArgumentException("Unknown URI " + uri); } ContentValues values; if (initialValues != null) { values=new ContentValues(initialValues); } else { values=new ContentValues(); } if (values.containsKey(MainTable.COLUMN_NAME_DATA) == false) { values.put(MainTable.COLUMN_NAME_DATA,""); } SQLiteDatabase db=mOpenHelper.getWritableDatabase(); long rowId=db.insert(MainTable.TABLE_NAME,null,values); if (rowId > 0) { Uri noteUri=ContentUris.withAppendedId(MainTable.CONTENT_ID_URI_BASE,rowId); getContext().getContentResolver().notifyChange(noteUri,null); return noteUri; } throw new SQLException("Failed to insert row into " + uri); }
Example 36
From project mediaphone, under directory /src/ac/robinson/mediaphone/provider/.
Source file: MediaPhoneProvider.java

public Uri insert(Uri uri,ContentValues initialValues){ ContentValues values; if (initialValues != null) { values=new ContentValues(initialValues); } else { throw new IllegalArgumentException("No content values passed"); } getType(uri); SQLiteDatabase db=mOpenHelper.getWritableDatabase(); long rowId=0; Uri contentUri=null; switch (URI_MATCHER.match(uri)) { case R.id.uri_narratives: rowId=db.insert(NARRATIVES_LOCATION,null,values); contentUri=NarrativeItem.NARRATIVE_CONTENT_URI; break; case R.id.uri_frames: rowId=db.insert(FRAMES_LOCATION,null,values); contentUri=FrameItem.CONTENT_URI; break; case R.id.uri_media: rowId=db.insert(MEDIA_LOCATION,null,values); contentUri=MediaItem.CONTENT_URI; break; case R.id.uri_templates: rowId=db.insert(TEMPLATES_LOCATION,null,values); contentUri=NarrativeItem.TEMPLATE_CONTENT_URI; break; } if (rowId > 0) { Uri insertUri=ContentUris.withAppendedId(contentUri,rowId); getContext().getContentResolver().notifyChange(uri,null); return insertUri; } throw new SQLException("Failed to insert row into " + uri); }
Example 37
From project mobilis, under directory /MXA/src/de/tudresden/inf/rn/mobilis/mxa/provider/.
Source file: MessageProvider.java

@Override public Uri insert(Uri uri,ContentValues initialValues){ Log.i("mobilis","saving with uri " + uri.toString()); if (sUriMatcher.match(uri) != MESSAGES) { throw new IllegalArgumentException("Unknown URI " + uri); } ContentValues values=checkValues(initialValues); SQLiteDatabase db=mOpenHelper.getWritableDatabase(); long rowId=db.insert(MESSAGES_TABLE_NAME,MessageItems.BODY,values); if (rowId > 0) { Uri noteUri=ContentUris.withAppendedId(MessageItems.CONTENT_URI,rowId); getContext().getContentResolver().notifyChange(noteUri,null); return noteUri; } throw new SQLException("Failed to insert row into " + uri); }
Example 38
From project NotePad, under directory /src/com/nononsenseapps/notepad/.
Source file: NotePadProvider.java

synchronized private Uri insertList(Uri uri,ContentValues initialValues){ Log.d(TAG,"insertList"); ContentValues values; if (initialValues != null) { values=new ContentValues(initialValues); } else { values=new ContentValues(); } if (values.containsKey(NotePad.Lists.COLUMN_NAME_TITLE) == false) { Resources r=Resources.getSystem(); values.put(NotePad.Lists.COLUMN_NAME_TITLE,r.getString(android.R.string.untitled)); } if (values.containsKey(NotePad.Lists.COLUMN_NAME_MODIFIED) == false) { values.put(NotePad.Lists.COLUMN_NAME_MODIFIED,1); } if (values.containsKey(NotePad.Lists.COLUMN_NAME_DELETED) == false) { values.put(NotePad.Lists.COLUMN_NAME_DELETED,0); } Long now=Long.valueOf(System.currentTimeMillis()); if (values.containsKey(NotePad.Lists.COLUMN_NAME_MODIFICATION_DATE) == false) { values.put(NotePad.Lists.COLUMN_NAME_MODIFICATION_DATE,now); } SQLiteDatabase db=mOpenHelper.getWritableDatabase(); long rowId=db.insert(NotePad.Lists.TABLE_NAME,NotePad.Lists.COLUMN_NAME_TITLE,values); if (rowId > 0) { Uri noteUri=ContentUris.withAppendedId(NotePad.Lists.CONTENT_ID_URI_BASE,rowId); return noteUri; } throw new SQLException("Failed to insert row into " + uri); }
Example 39
From project opensudoku, under directory /OpenSudoku/src/cz/romario/opensudoku/db/.
Source file: SudokuDatabase.java

/** * Inserts new puzzle folder into the database. * @param name Name of the folder. * @param created Time of folder creation. * @return */ public FolderInfo insertFolder(String name,Long created){ ContentValues values=new ContentValues(); values.put(FolderColumns.CREATED,created); values.put(FolderColumns.NAME,name); long rowId; SQLiteDatabase db=mOpenHelper.getWritableDatabase(); rowId=db.insert(FOLDER_TABLE_NAME,FolderColumns._ID,values); if (rowId > 0) { FolderInfo fi=new FolderInfo(); fi.id=rowId; fi.name=name; return fi; } throw new SQLException(String.format("Failed to insert folder '%s'.",name)); }
Example 40
From project opensudoku-blackberry, under directory /opensudoku/src/net/bmagro/blackberry/opensudoku/db/.
Source file: SudokuDatabase.java

/** * Inserts new puzzle folder into the database. * @param name Name of the folder. * @param created Time of folder creation. * @return */ public FolderInfo insertFolder(String name,Long created){ ContentValues values=new ContentValues(); values.put(FolderColumns.CREATED,created); values.put(FolderColumns.NAME,name); long rowId; SQLiteDatabase db=mOpenHelper.getWritableDatabase(); rowId=db.insert(FOLDER_TABLE_NAME,FolderColumns._ID,values); if (rowId > 0) { FolderInfo fi=new FolderInfo(); fi.id=rowId; fi.name=name; return fi; } throw new SQLException(String.format("Failed to insert folder '%s'.",name)); }
Example 41
From project persistence, under directory /src/main/java/com/codeslap/persistence/.
Source file: BaseContentProvider.java

@Override public Uri insert(Uri uri,ContentValues initialValues){ int id=sUriMatcher.match(uri); if (!TABLE_NAME_IDS.containsKey(id)) { throw new IllegalArgumentException("Unknown URI " + uri + "; id "+ id+ "; "+ TABLE_NAME_IDS); } if (initialValues == null) { initialValues=new ContentValues(); } String tableName=TABLE_NAME_IDS.get(id); long rowId=getDatabase().insert(tableName,null,initialValues); if (rowId > 0) { Uri CONTENT_URI=Uri.parse(String.format("content://%s/%s",getAuthority(),tableName)); Uri beanUri=ContentUris.withAppendedId(CONTENT_URI,rowId); getContext().getContentResolver().notifyChange(beanUri,null); return beanUri; } throw new SQLException("Failed to insert row into " + uri); }
Example 42
From project platform_packages_apps_alarmclock, under directory /src/com/android/alarmclock/.
Source file: AlarmProvider.java

@Override public Uri insert(Uri url,ContentValues initialValues){ if (sURLMatcher.match(url) != ALARMS) { throw new IllegalArgumentException("Cannot insert into URL: " + url); } ContentValues values; if (initialValues != null) values=new ContentValues(initialValues); else values=new ContentValues(); if (!values.containsKey(Alarm.Columns.HOUR)) values.put(Alarm.Columns.HOUR,0); if (!values.containsKey(Alarm.Columns.MINUTES)) values.put(Alarm.Columns.MINUTES,0); if (!values.containsKey(Alarm.Columns.DAYS_OF_WEEK)) values.put(Alarm.Columns.DAYS_OF_WEEK,0); if (!values.containsKey(Alarm.Columns.ALARM_TIME)) values.put(Alarm.Columns.ALARM_TIME,0); if (!values.containsKey(Alarm.Columns.ENABLED)) values.put(Alarm.Columns.ENABLED,0); if (!values.containsKey(Alarm.Columns.VIBRATE)) values.put(Alarm.Columns.VIBRATE,1); if (!values.containsKey(Alarm.Columns.MESSAGE)) values.put(Alarm.Columns.MESSAGE,""); if (!values.containsKey(Alarm.Columns.ALERT)) values.put(Alarm.Columns.ALERT,""); SQLiteDatabase db=mOpenHelper.getWritableDatabase(); long rowId=db.insert("alarms",Alarm.Columns.MESSAGE,values); if (rowId < 0) { throw new SQLException("Failed to insert row into " + url); } if (Log.LOGV) Log.v("Added alarm rowId = " + rowId); Uri newUrl=ContentUris.withAppendedId(Alarm.Columns.CONTENT_URI,rowId); getContext().getContentResolver().notifyChange(newUrl,null); return newUrl; }
Example 43
From project AirCastingAndroidClient, under directory /src/main/java/pl/llp/aircasting/repository/.
Source file: MeasurementRepository.java

@Internal void deleteAllFrom(Long streamId,SQLiteDatabase writableDatabase){ try { writableDatabase.delete(MEASUREMENT_TABLE_NAME,MEASUREMENT_STREAM_ID + " = " + streamId,null); } catch ( SQLException e) { Log.e(Constants.TAG,"Error removing measurements from stream [" + streamId + "]",e); } }
Example 44
From project and-bible, under directory /AndBible/src/net/bible/service/db/bookmark/.
Source file: BookmarkDBAdapter.java

public BookmarkDBAdapter open() throws SQLException { try { db=dbHelper.getWritableDatabase(); } catch ( SQLiteException ex) { db=dbHelper.getReadableDatabase(); } return this; }
Example 45
From project andlytics, under directory /src/com/github/andlyticsproject/db/.
Source file: AndlyticsContentProvider.java

public long getAppStatsIdByDate(String packagename,Date date,SQLiteDatabase db) throws SQLException { long result=-1; SimpleDateFormat dateFormatStart=new SimpleDateFormat("yyyy-MM-dd 00:00:00"); SimpleDateFormat dateFormatEnd=new SimpleDateFormat("yyyy-MM-dd 23:59:59"); Cursor mCursor=db.query(AppStatsTable.DATABASE_TABLE_NAME,new String[]{AppStatsTable.KEY_ROWID,AppStatsTable.KEY_STATS_REQUESTDATE},AppStatsTable.KEY_STATS_PACKAGENAME + "='" + packagename+ "' and "+ AppStatsTable.KEY_STATS_REQUESTDATE+ " BETWEEN '"+ dateFormatStart.format(date)+ "' and '"+ dateFormatEnd.format(date)+ "'",null,null,null,null); if (mCursor != null && mCursor.moveToFirst()) { result=mCursor.getInt(mCursor.getColumnIndex(AppStatsTable.KEY_ROWID)); } mCursor.close(); return result; }
Example 46
From project Android, under directory /app/src/main/java/com/github/mobile/sync/.
Source file: SyncCampaign.java

public void run(){ List<User> orgs; try { orgs=cache.requestAndStore(persistedOrgs); syncResult.stats.numUpdates++; } catch ( IOException e) { syncResult.stats.numIoExceptions++; Log.d(TAG,"Exception requesting users and orgs",e); return; } catch ( 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.getLogin() + "..."); try { cache.requestAndStore(repos.under(org)); syncResult.stats.numUpdates++; } catch ( IOException e) { syncResult.stats.numIoExceptions++; Log.d(TAG,"Exception requesting repositories",e); } catch ( SQLException e) { syncResult.stats.numIoExceptions++; Log.d(TAG,"Exception requesting repositories",e); } } Log.d(TAG,"Sync campaign finished"); }
Example 47
From project android-joedayz, under directory /Proyectos/TareasSQLite/src/com/androideity/tareasqlite/database/.
Source file: DBAdapter.java

public Cursor fetchTodo(long rowId) throws SQLException { Cursor mCursor=database.query(true,DATABASE_TABLE,new String[]{KEY_ROWID,KEY_CATEGORY,KEY_SUMMARY,KEY_DESCRIPTION},KEY_ROWID + "=" + rowId,null,null,null,null,null); if (mCursor != null) { mCursor.moveToFirst(); } return mCursor; }
Example 48
From project androidtracks, under directory /src/org/sfcta/cycletracks/.
Source file: DbAdapter.java

/** * Return a Cursor positioned at the trip that matches the given rowId * @param rowId id of trip to retrieve * @return Cursor positioned to matching trip, if found * @throws SQLException if trip could not be found/retrieved */ public Cursor fetchTrip(long rowId) throws SQLException { Cursor mCursor=mDb.query(true,DATA_TABLE_TRIPS,new String[]{K_TRIP_ROWID,K_TRIP_PURP,K_TRIP_START,K_TRIP_FANCYSTART,K_TRIP_NOTE,K_TRIP_LATHI,K_TRIP_LATLO,K_TRIP_LGTHI,K_TRIP_LGTLO,K_TRIP_STATUS,K_TRIP_END,K_TRIP_FANCYINFO,K_TRIP_DISTANCE},K_TRIP_ROWID + "=" + rowId,null,null,null,null,null); if (mCursor != null) { mCursor.moveToFirst(); } return mCursor; }
Example 49
From project Birthdays, under directory /src/com/rexmenpara/birthdays/db/.
Source file: DBAdapter.java

/** * Retrieves a particular entry * @param rowId * @return * @throws SQLException */ public Cursor getEntry(long rowId) throws SQLException { Cursor mCursor=db.query(true,DATABASE_TABLE,new String[]{KEY_ROWID,KEY_NAME,KEY_CONTACTID,KEY_BDAY,KEY_EVENTID,KEY_REMINDER},KEY_ROWID + "=" + rowId,null,null,null,null,null); if (mCursor != null) { mCursor.moveToFirst(); } return mCursor; }
Example 50
From project Bitcoin-Wallet-for-Android, under directory /wallet/src/de/schildbach/wallet/store/.
Source file: SQLiteBlockStore.java

private void flushCache() throws SQLException { final SQLiteDatabase db=helper.getWritableDatabase(); try { db.beginTransaction(); final SQLiteStatement insert=db.compileStatement("INSERT OR REPLACE INTO " + TABLE_BLOCKS + " ("+ COLUMN_BLOCKS_HASH+ ","+ COLUMN_BLOCKS_CHAINWORK+ ","+ COLUMN_BLOCKS_HEIGHT+ ","+ COLUMN_BLOCKS_HEADER+ ") VALUES (?, ?, ?, ?)"); for ( final StoredBlock block : writeAheadCache.values()) { insert.bindBlob(1,block.getHeader().getHash().getBytes()); insert.bindBlob(2,block.getChainWork().toByteArray()); insert.bindLong(3,block.getHeight()); insert.bindBlob(4,block.getHeader().unsafeBitcoinSerialize()); final long result=insert.executeInsert(); if (result == -1) throw new RuntimeException("insert not successful"); } insert.close(); final ContentValues settingValues=new ContentValues(); settingValues.put(COLUMN_SETTINGS_NAME,SETTING_CHAINHEAD); settingValues.put(COLUMN_SETTINGS_VALUE,chainHeadBlock.getHeader().getHash().getBytes()); db.replaceOrThrow(TABLE_SETTINGS,null,settingValues); db.setTransactionSuccessful(); writeAheadCache.clear(); } finally { db.endTransaction(); } }
Example 51
From project BombusLime, under directory /src/org/bombusim/lime/data/.
Source file: AccountDbAdapter.java

public void open(){ try { db=dbHelper.getWritableDatabase(); } catch ( SQLException ex) { db=dbHelper.getReadableDatabase(); } }
Example 52
From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.
Source file: CatalogueDBAdapter.java

/** * Open the books database. If it cannot be opened, try to create a new instance of the database. If it cannot be created, throw an exception to signal the failure * @return this (self reference, allowing this to be chained in an initialisation call) * @throws SQLException if the database could be neither opened or created */ public CatalogueDBAdapter open() throws SQLException { StorageUtils.getSharedStorage(); mDb=new SynchronizedDb(mDbHelper,mSynchronizer); mDb.execSQL("PRAGMA foreign_keys = ON"); mStatements=new SqlStatementManager(mDb); return this; }
Example 53
From project Cafe, under directory /testservice/src/com/baidu/cafe/remote/.
Source file: SystemLib.java

public int insertAPN(String name,String apn_addr,String proxy,String port){ int id=-1; ContentResolver resolver=mContext.getContentResolver(); ContentValues values=new ContentValues(); values.put("name",name); values.put("apn",apn_addr); values.put(Telephony.Carriers.PROXY,proxy); values.put(Telephony.Carriers.PORT,port); values.put("mcc","310"); values.put("mnc","260"); values.put("numeric","310260"); Cursor c=null; try { resolver.delete(APN_TABLE_URI,"_id=?",null); Uri newRow=resolver.insert(APN_TABLE_URI,values); if (newRow != null) { c=resolver.query(newRow,null,null,null,null); Log.print("Newly added APN:"); int idindex=c.getColumnIndex("_id"); c.moveToFirst(); id=c.getShort(idindex); Log.print("New ID: " + id + ": Inserting new APN succeeded!"); if (setDefaultAPN(id)) { Log.print("Set apn to default success!"); } else { Log.print("Set apn to default fail!"); } } } catch ( SQLException e) { Log.print(e.getMessage()); } if (c != null) c.close(); return id; }
Example 54
From project callmeter, under directory /src/de/ub0r/android/callmeter/data/.
Source file: DataProvider.java

/** * Reload backup into table. * @param db {@link SQLiteDatabase} * @param table table * @param values {@link ContentValues}[] backed up with backup() */ private static void reload(final SQLiteDatabase db,final String table,final ContentValues[] values){ if (values == null || values.length == 0) { return; } Log.d(TAG,"reload(db, " + table + ", cv["+ values.length+ "])"); db.beginTransaction(); try { for ( ContentValues cv : values) { Log.d(TAG,"reload: " + table + " inert: "+ cv); db.insert(table,null,cv); } db.setTransactionSuccessful(); } catch ( SQLException e) { Log.e(TAG,"error reloading row: " + table,e); } finally { db.endTransaction(); } return; }
Example 55
From project Common-Sense-Net-2, under directory /RealFarm/src/com/commonsensenet/realfarm/dataaccess/.
Source file: RealFarmDatabase.java

public long deleteEntriesdb(String TableName,String whereClause,String[] whereArgs){ long result=-1; if (TableName != null) { try { result=mDb.delete(TableName,whereClause,whereArgs); } catch ( SQLException e) { Log.d(LOG_TAG,"Exception" + e); } } return result; }
Example 56
From project DownloadProvider, under directory /src/com/mozillaonline/providers/downloads/.
Source file: DownloadProvider.java

/** * Creates the table that'll hold the download information. */ private void createDownloadsTable(SQLiteDatabase db){ try { db.execSQL("DROP TABLE IF EXISTS " + DB_TABLE); db.execSQL("CREATE TABLE " + DB_TABLE + "("+ Downloads._ID+ " INTEGER PRIMARY KEY AUTOINCREMENT,"+ Downloads.COLUMN_URI+ " TEXT, "+ Constants.RETRY_AFTER_X_REDIRECT_COUNT+ " INTEGER, "+ Downloads.COLUMN_APP_DATA+ " TEXT, "+ Downloads.COLUMN_NO_INTEGRITY+ " BOOLEAN, "+ Downloads.COLUMN_FILE_NAME_HINT+ " TEXT, "+ Constants.OTA_UPDATE+ " BOOLEAN, "+ Downloads._DATA+ " TEXT, "+ Downloads.COLUMN_MIME_TYPE+ " TEXT, "+ Downloads.COLUMN_DESTINATION+ " INTEGER, "+ Constants.NO_SYSTEM_FILES+ " BOOLEAN, "+ Downloads.COLUMN_VISIBILITY+ " INTEGER, "+ Downloads.COLUMN_CONTROL+ " INTEGER, "+ Downloads.COLUMN_STATUS+ " INTEGER, "+ Constants.FAILED_CONNECTIONS+ " INTEGER, "+ Downloads.COLUMN_LAST_MODIFICATION+ " BIGINT, "+ Downloads.COLUMN_NOTIFICATION_PACKAGE+ " TEXT, "+ Downloads.COLUMN_NOTIFICATION_CLASS+ " TEXT, "+ Downloads.COLUMN_NOTIFICATION_EXTRAS+ " TEXT, "+ Downloads.COLUMN_COOKIE_DATA+ " TEXT, "+ Downloads.COLUMN_USER_AGENT+ " TEXT, "+ Downloads.COLUMN_REFERER+ " TEXT, "+ Downloads.COLUMN_TOTAL_BYTES+ " INTEGER, "+ Downloads.COLUMN_CURRENT_BYTES+ " INTEGER, "+ Constants.ETAG+ " TEXT, "+ Constants.UID+ " INTEGER, "+ Downloads.COLUMN_OTHER_UID+ " INTEGER, "+ Downloads.COLUMN_TITLE+ " TEXT, "+ Downloads.COLUMN_DESCRIPTION+ " TEXT); "); } catch ( SQLException ex) { Log.e(Constants.TAG,"couldn't create table in downloads database"); throw ex; } }
Example 57
From project droidparts, under directory /base/src/org/droidparts/persist/sql/.
Source file: AbstractEntityManager.java

public boolean create(EntityType item){ createOrUpdateForeignKeys(item); ContentValues cv=toContentValues(item); cv.remove(DB.Column.ID); long id=0; try { id=getDB().insertOrThrow(getTableName(),null,cv); } catch ( SQLException e) { L.e(e.getMessage()); L.d(e); } if (id > 0) { item.id=id; return true; } else { return false; } }
Example 58
From project fanfoudroid, under directory /src/com/ch_linghu/fanfoudroid/db2/.
Source file: FanDatabase.java

private static void resetAllTables(SQLiteDatabase db,int oldVersion,int newVersion){ try { dropAllTables(db); } catch ( SQLException e) { Log.e(TAG,"resetAllTables ERROR!"); } createAllTables(db); }
Example 59
From project farebot, under directory /src/com/codebutler/farebot/felica/.
Source file: DBUtil.java

public SQLiteDatabase openDatabase() throws SQLException, IOException { if (mDatabase != null) { return mDatabase; } if (!this.hasDatabase()) { this.copyDatabase(); } mDatabase=SQLiteDatabase.openDatabase(new File(DB_PATH,DB_NAME).getPath(),null,SQLiteDatabase.OPEN_READONLY); return mDatabase; }
Example 60
From project FBReaderJ, under directory /src/org/geometerplus/android/fbreader/library/.
Source file: SQLiteBooksDatabase.java

protected void saveBookAuthorInfo(long bookId,long index,Author author){ if (myGetAuthorIdStatement == null) { myGetAuthorIdStatement=myDatabase.compileStatement("SELECT author_id FROM Authors WHERE name = ? AND sort_key = ?"); myInsertAuthorStatement=myDatabase.compileStatement("INSERT OR IGNORE INTO Authors (name,sort_key) VALUES (?,?)"); myInsertBookAuthorStatement=myDatabase.compileStatement("INSERT OR REPLACE INTO BookAuthor (book_id,author_id,author_index) VALUES (?,?,?)"); } long authorId; try { myGetAuthorIdStatement.bindString(1,author.DisplayName); myGetAuthorIdStatement.bindString(2,author.SortKey); authorId=myGetAuthorIdStatement.simpleQueryForLong(); } catch ( SQLException e) { myInsertAuthorStatement.bindString(1,author.DisplayName); myInsertAuthorStatement.bindString(2,author.SortKey); authorId=myInsertAuthorStatement.executeInsert(); } myInsertBookAuthorStatement.bindLong(1,bookId); myInsertBookAuthorStatement.bindLong(2,authorId); myInsertBookAuthorStatement.bindLong(3,index); myInsertBookAuthorStatement.execute(); }
Example 61
From project FlipDroid, under directory /app/src/com/goal98/flipdroid2/db/.
Source file: AbstractDB.java

private void createRecommandTable(SQLiteDatabase sqLiteDatabase){ Log.w(this.getClass().getName(),"Creating table " + RecommendSource.TABLE_NAME); try { sqLiteDatabase.execSQL(RECOMMAND_SOURCE_TABLE_CREATE); } catch ( SQLException e) { Log.e(this.getClass().getName(),e.getMessage(),e); } }
Example 62
From project GnucashMobile, under directory /GnucashMobile/src/org/gnucash/android/db/.
Source file: DatabaseAdapter.java

/** * Opens/creates database to be used for reading or writing. * @return Reference to self for database manipulation */ public DatabaseAdapter open(){ try { mDb=mDbHelper.getWritableDatabase(); } catch ( SQLException e) { Log.e(TAG,"Error getting database: " + e.getMessage()); mDb=mDbHelper.getReadableDatabase(); } return this; }
Example 63
From project greenDAO, under directory /DaoCore/src/de/greenrobot/dao/test/.
Source file: AbstractDaoTestSinglePk.java

public void testInsertTwice(){ K pk=nextPk(); T entity=createEntity(pk); dao.insert(entity); try { dao.insert(entity); fail("Inserting twice should not work"); } catch ( SQLException expected) { } }
Example 64
From project jamendo-android, under directory /src/com/teleca/jamendo/util/download/.
Source file: DownloadDatabaseImpl.java

private SQLiteDatabase getDb(){ boolean success=(new File("/sdcard/music")).mkdirs(); if (success) { Log.i(JamendoApplication.TAG,"Directory: " + "/sdcard/music" + " created"); } try { return SQLiteDatabase.openDatabase(mPath,null,SQLiteDatabase.CREATE_IF_NECESSARY); } catch ( SQLException e) { Log.e(JamendoApplication.TAG,"Failed creating database"); e.printStackTrace(); return null; } }
Example 65
From project keepassdroid, under directory /src/com/keepassdroid/fileselect/.
Source file: FileDbHelper.java

public Cursor fetchFile(long fileId) throws SQLException { Cursor cursor=mDb.query(true,FILE_TABLE,new String[]{KEY_FILE_FILENAME,KEY_FILE_KEYFILE},KEY_FILE_ID + "=" + fileId,null,null,null,null,null); if (cursor != null) { cursor.moveToFirst(); } return cursor; }
Example 66
From project MIT-Mobile-for-Android, under directory /src/edu/mit/mitmobile2/facilities/.
Source file: FacilitiesDB.java

private static void createCategoryTable(SQLiteDatabase db){ String categoryTableSql="CREATE TABLE \n" + CATEGORY_TABLE + "\n ("+ CategoryTable._ID+ " INTEGER PRIMARY KEY AUTOINCREMENT, \n"+ CategoryTable.ID+ " TEXT, \n "+ CategoryTable.NAME+ " TEXT \n "+ ");"; try { db.execSQL(categoryTableSql); } catch ( SQLException e) { Log.d(TAG,e.getMessage()); } }
Example 67
From project MyExpenses, under directory /src/org/totschnig/myexpenses/.
Source file: ExpensesDbAdapter.java

/** * Return a Cursor positioned at the transaction that matches the given rowId exposes just the label for the linked category * @param rowId id of transaction to retrieve * @return Cursor positioned to matching transaction, if found * @throws SQLException if transaction could not be found/retrieved */ public Cursor fetchTransaction(long rowId) throws SQLException { Cursor mCursor=mDb.query(DATABASE_TABLE,new String[]{KEY_ROWID,KEY_DATE,KEY_AMOUNT,KEY_COMMENT,KEY_CATID,SHORT_LABEL,KEY_PAYEE,KEY_TRANSFER_PEER,KEY_ACCOUNTID,KEY_METHODID},KEY_ROWID + "=" + rowId,null,null,null,null,null); if (mCursor != null) { mCursor.moveToFirst(); } return mCursor; }
Example 68
From project mythmote, under directory /src/tkj/android/homecontrol/mythmote/db/.
Source file: MythMoteDbManager.java

/** * Return a Cursor positioned at the note that matches the given rowId * @param rowId id of note to retrieve * @return Cursor positioned to matching note, if found */ public Cursor fetchFrontendLocation(long rowId){ Cursor mCursor=null; try { mCursor=db.query(true,FRONTEND_TABLE,new String[]{KEY_ROWID,KEY_NAME,KEY_ADDRESS,KEY_PORT},KEY_ROWID + "=" + rowId,null,null,null,null,null); if (mCursor != null) { mCursor.moveToFirst(); } } catch ( SQLException e) { AlertDialog.Builder builder=new AlertDialog.Builder(context); builder.setTitle("DataBase Error"); builder.setMessage(e.getLocalizedMessage()); builder.setNeutralButton(R.string.ok_str,new OnClickListener(){ public void onClick( DialogInterface dialog, int which){ } } ); } return mCursor; }
Example 69
From project npr-android-app, under directory /src/org/npr/android/util/.
Source file: PlaylistProvider.java

@Override public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion){ Log.w(PlaylistHelper.class.getName(),"Upgrading database from version " + oldVersion + " to "+ newVersion); if (newVersion <= 3) { try { db.execSQL("ALTER TABLE " + TABLE_NAME + " ADD COLUMN "+ Items.STORY_ID+ " TEXT DEFAULT NULL;"); } catch ( SQLException error) { Log.e(LOG_TAG,error.toString()); } } }
Example 70
From project official-android-app--DEPRECATED-, under directory /src/com/plancake/android/app/.
Source file: DbAdapter.java

/** * We don't need to specify the parameter 'deep' (as for the other similar methods) because the insertTask method populated also the tasks_tags table */ public long replaceOrInsertTask(PlancakeTaskForApi task,boolean isModifiedLocally) throws java.sql.SQLException { long ret=0; db.beginTransaction(); try { deleteTask(task); ret=insertTask(task,isModifiedLocally); db.setTransactionSuccessful(); } finally { db.endTransaction(); } return ret; }
Example 71
From project ohmagePhone, under directory /src/org/ohmage/prompt/multichoicecustom/.
Source file: MultiChoiceCustomDbAdapter.java

public boolean open(){ mDbHelper=new DatabaseHelper(mContext); try { mDb=mDbHelper.getWritableDatabase(); } catch ( SQLException e) { Log.e(TAG,e.toString()); return false; } return true; }
Example 72
From project Ohmage_Phone, under directory /src/org/ohmage/prompt/multichoicecustom/.
Source file: MultiChoiceCustomDbAdapter.java

public boolean open(){ Log.i(TAG,"DB: open"); mDbHelper=new DatabaseHelper(mContext); try { mDb=mDbHelper.getWritableDatabase(); } catch ( SQLException e) { Log.e(TAG,e.toString()); return false; } return true; }
Example 73
From project platform_packages_providers_calendarprovider, under directory /src/com/android/providers/calendar/.
Source file: CalendarDatabaseHelper.java

private void dropTables(SQLiteDatabase db){ Log.i(TAG,"Clearing database"); String[] columns={"type","name"}; Cursor cursor=db.query("sqlite_master",columns,null,null,null,null,null); if (cursor == null) { return; } try { while (cursor.moveToNext()) { final String name=cursor.getString(1); if (!name.startsWith("sqlite_")) { final String sql="DROP " + cursor.getString(0) + " IF EXISTS "+ name; try { db.execSQL(sql); } catch ( SQLException e) { Log.e(TAG,"Error executing " + sql + " "+ e.toString()); } } } } finally { cursor.close(); } }
Example 74
From project platform_packages_providers_downloadprovider, under directory /src/com/android/providers/downloads/.
Source file: DownloadProvider.java

/** * Creates the table that'll hold the download information. */ private void createDownloadsTable(SQLiteDatabase db){ try { db.execSQL("DROP TABLE IF EXISTS " + DB_TABLE); db.execSQL("CREATE TABLE " + DB_TABLE + "("+ Downloads.Impl._ID+ " INTEGER PRIMARY KEY AUTOINCREMENT,"+ Downloads.Impl.COLUMN_URI+ " TEXT, "+ Constants.RETRY_AFTER_X_REDIRECT_COUNT+ " INTEGER, "+ Downloads.Impl.COLUMN_APP_DATA+ " TEXT, "+ Downloads.Impl.COLUMN_NO_INTEGRITY+ " BOOLEAN, "+ Downloads.Impl.COLUMN_FILE_NAME_HINT+ " TEXT, "+ Constants.OTA_UPDATE+ " BOOLEAN, "+ Downloads.Impl._DATA+ " TEXT, "+ Downloads.Impl.COLUMN_MIME_TYPE+ " TEXT, "+ Downloads.Impl.COLUMN_DESTINATION+ " INTEGER, "+ Constants.NO_SYSTEM_FILES+ " BOOLEAN, "+ Downloads.Impl.COLUMN_VISIBILITY+ " INTEGER, "+ Downloads.Impl.COLUMN_CONTROL+ " INTEGER, "+ Downloads.Impl.COLUMN_STATUS+ " INTEGER, "+ Constants.FAILED_CONNECTIONS+ " INTEGER, "+ Downloads.Impl.COLUMN_LAST_MODIFICATION+ " BIGINT, "+ Downloads.Impl.COLUMN_NOTIFICATION_PACKAGE+ " TEXT, "+ Downloads.Impl.COLUMN_NOTIFICATION_CLASS+ " TEXT, "+ Downloads.Impl.COLUMN_NOTIFICATION_EXTRAS+ " TEXT, "+ Downloads.Impl.COLUMN_COOKIE_DATA+ " TEXT, "+ Downloads.Impl.COLUMN_USER_AGENT+ " TEXT, "+ Downloads.Impl.COLUMN_REFERER+ " TEXT, "+ Downloads.Impl.COLUMN_TOTAL_BYTES+ " INTEGER, "+ Downloads.Impl.COLUMN_CURRENT_BYTES+ " INTEGER, "+ Constants.ETAG+ " TEXT, "+ Constants.UID+ " INTEGER, "+ Downloads.Impl.COLUMN_OTHER_UID+ " INTEGER, "+ Downloads.Impl.COLUMN_TITLE+ " TEXT, "+ Downloads.Impl.COLUMN_DESCRIPTION+ " TEXT, "+ Constants.MEDIA_SCANNED+ " BOOLEAN);"); } catch ( SQLException ex) { Log.e(Constants.TAG,"couldn't create table in downloads database"); throw ex; } }