Example usage for android.database SQLException getMessage

List of usage examples for android.database SQLException getMessage

Introduction

In this page you can find the example usage for android.database SQLException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.adam.aslfms.StatusActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.status_activity);

    settings = new AppSettings(this);

    mDb = new ScrobblesDatabase(this);

    try {/*from  w ww  .j  a v  a2 s.  c  o m*/
        mDb.open();
    } catch (SQLException e) {
        Log.e(TAG, "Cannot open database!");
        Log.e(TAG, e.getMessage());
        mDb = null;
    }

    //getSupportActionBar().setElevation(0);
    //Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    //setSupportActionBar(toolbar);
    //getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // manifest android:theme="@style/Theme.AppCompat.NoActionBar"

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    if (viewPager != null) {
        setupViewPager(viewPager);
    }

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
}

From source file:com.adam.aslfms.SettingsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.settings_prefs);

    settings = new AppSettings(this);

    mDb = new ScrobblesDatabase(this);

    try {// w w w. j  a  v a 2 s. co m
        mDb.open();
    } catch (SQLException e) {
        Log.e(TAG, "Cannot open database!");
        Log.e(TAG, e.getMessage());
        mDb = null;
    }

    mHeartCurrentTrack = findPreference(KEY_HEART_CURRENT_TRACK);
    mScrobbleAllNow = findPreference(KEY_SCROBBLE_ALL_NOW);
    mViewScrobbleCache = findPreference(KEY_VIEW_SCROBBLE_CACHE);
    mCopyCurrentTrack = findPreference(KEY_COPY_CURRENT_TRACK);

    checkNetwork();
    permsCheck();
    credsCheck();

    int v = Util.getAppVersionCode(this, getPackageName());
    if (settings.getWhatsNewViewedVersion() < v) {
        new WhatsNewDialog(this).show();
        settings.setWhatsNewViewedVersion(v);
    }
}

From source file:edu.pdx.cecs.orcycle.FragmentSavedNotesSection.java

void populateNoteList(ListView lv) {
    // Get list from the real phone database. W00t!
    final DbAdapter mDb = new DbAdapter(getActivity());
    //mDb.open();
    mDb.openReadOnly();/*ww w  .java  2 s.  c  o  m*/
    try {
        allNotes = mDb.fetchAllNotes();
        Log.e(MODULE_TAG, "------------------> populateNoteList()");

        String[] from = new String[] { "noteseverity", "noterecorded" };
        int[] to = new int[] { R.id.tvSnliNoteSeverity, R.id.tvSnliRecorded };

        sna = new SavedNotesAdapter(getActivity(), R.layout.saved_notes_list_item, allNotes, from, to,
                CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

        lv.setAdapter(sna);
    } catch (SQLException ex) {
        Log.e(MODULE_TAG, ex.getMessage());
        // Do nothing, for now!
    } catch (Exception ex) {
        Log.e(MODULE_TAG, ex.getMessage());
    }
    mDb.close();

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int pos, long noteId) {
            Log.v(MODULE_TAG,
                    "onItemClick (id = " + String.valueOf(noteId) + ", pos = " + String.valueOf(pos) + ")");
            try {
                if (mActionModeNote == null) {

                    // If the note has just been recently scheduled, we won't ask the user
                    // if they want to upload it.  This fixes a bug whereby the note is
                    // in the process of uploading, but the user wants to see it now.
                    if (NoteUploader.isPending(noteId)) {
                        transitionToNoteMapActivity(noteId);
                    } else {
                        final DbAdapter mDb = new DbAdapter(getActivity());
                        mDb.openReadOnly();
                        try {
                            int noteStatus = mDb.getNoteStatus(noteId);
                            if (noteStatus == 2) {
                                transitionToNoteMapActivity(noteId);
                            } else if (noteStatus == 1) {
                                buildAlertMessageUnuploadedNoteClicked(noteId);
                            }
                        } catch (Exception ex) {
                            Log.e(MODULE_TAG, ex.getMessage());
                        } finally {
                            mDb.close();
                        }
                    }
                } else {
                    // highlight
                    if (noteIdArray.indexOf(noteId) > -1) {
                        noteIdArray.remove(noteId);
                        v.setBackgroundColor(Color.parseColor("#80ffffff"));
                    } else {
                        noteIdArray.add(noteId);
                        v.setBackgroundColor(Color.parseColor("#ff33b5e5"));
                    }
                    // Toast.makeText(getActivity(), "Selected: " + noteIdArray,
                    // Toast.LENGTH_SHORT).show();
                    if (noteIdArray.size() == 0) {
                        saveMenuItemDelete.setEnabled(false);
                    } else {
                        saveMenuItemDelete.setEnabled(true);
                    }

                    mActionModeNote.setTitle(noteIdArray.size() + " Selected");
                }
            } catch (Exception ex) {
                Log.e(MODULE_TAG, ex.getMessage());
            }
        }
    });

    registerForContextMenu(lv);
}

From source file:com.marianhello.bgloc.LocationService.java

public Long persistLocation(BackgroundLocation location) {
    Long locationId = -1L;/*from  ww w  .  ja  va 2s  .c  o m*/
    try {
        locationId = dao.persistLocationWithLimit(location, config.getMaxLocations());
        location.setLocationId(locationId);
        log.debug("Persisted location: {}", location.toString());
    } catch (SQLException e) {
        log.error("Failed to persist location: {} error: {}", location.toString(), e.getMessage());
    }

    return locationId;
}

From source file:de.nware.app.hsDroid.provider.onlineService2Provider.java

@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {

    Cursor cursor = null;//from ww  w  .  java 2 s .co m
    switch (mUriMatcher.match(uri)) {
    case EXAMS:
        SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
        qb.setTables(mOpenHelper.getTableName());
        qb.setProjectionMap(examsProjectionMap);
        SQLiteDatabase db = mOpenHelper.getReadableDatabase();
        try {
            cursor = qb.query(db, projection, selection, selectionArgs, null, null, sortOrder);
        } catch (SQLException e) {
            e.printStackTrace();
            Log.d(TAG, "SqlError: " + e.getMessage());
        }
        cursor.setNotificationUri(getContext().getContentResolver(), uri);
        break;
    case EXAMS_UPDATE:
        MatrixCursor cur = new MatrixCursor(EXAMS_UPDATE_COLUMNS);
        Integer[] columnValues = updateGrades();
        cur.addRow(new Object[] { 0, columnValues[0], columnValues[1] });
        return cur;
    case EXAMINFOS:
        cursor = getExamInfos(selectionArgs[0], selectionArgs[1], false);
        break;
    case CERTIFICATIONS:
        cursor = getCertifications();
        break;
    default:
        throw new IllegalArgumentException("Unbekannte URI " + uri);
    }

    return cursor;
}

From source file:eu.operando.operandoapp.database.DatabaseHelper.java

public void updateStatistics(final Set<RequestFilterUtil.FilterType> exfiltrated) {
    new Thread(new Runnable() {
        @Override/*from  w  w w .  ja va 2s .  c om*/
        public void run() {
            for (RequestFilterUtil.FilterType filter : exfiltrated) {
                String column = "";
                switch (RequestFilterUtil.getDescriptionForFilterType(filter)) {
                case "Contacts Data":
                    column = KEY_CONTACTSINFO;
                    break;
                case "IMEI":
                    column = KEY_IMEI;
                    break;
                case "Phone Number":
                    column = KEY_PHONENUMBER;
                    break;
                case "Device Id":
                    column = KEY_IMSI;
                    break;
                case "Carrier Name":
                    column = KEY_CARRIERNAME;
                    break;
                case "Location Information":
                    column = KEY_LOCATION;
                    break;
                case "Android Id":
                    column = KEY_ANDROIDID;
                    break;
                case "Mac Addresses":
                    column = KEY_MACADDRESSES;
                    break;
                }
                if (!column.equals("")) {
                    SQLiteDatabase db = DatabaseHelper.this.getWritableDatabase();
                    try {
                        db.execSQL("UPDATE " + TABLE_STATISTICS + " SET " + column + " = " + column
                                + "+1 WHERE " + KEY_ID + "=1");
                    } catch (SQLException sqle) {
                        sqle.getMessage();
                    }
                }
            }
        }
    }).start();
}

From source file:com.androzic.location.LocationService.java

public void addPoint(boolean continous, double latitude, double longitude, double elevation, float speed,
        float bearing, float accuracy, long time) {
    if (trackDB == null) {
        openDatabase();//from   w w  w  . j a  va 2s  . c  o m
        if (trackDB == null)
            return;
    }

    ContentValues values = new ContentValues();
    values.put("latitude", latitude);
    values.put("longitude", longitude);
    values.put("code", continous ? 0 : 1);
    values.put("elevation", elevation);
    values.put("speed", speed);
    values.put("track", bearing);
    values.put("accuracy", accuracy);
    values.put("datetime", time);

    try {
        trackDB.insertOrThrow("track", null, values);
    } catch (SQLException e) {
        Log.e(TAG, "addPoint", e);
        errorMsg = e.getMessage();
        errorTime = System.currentTimeMillis();
        updateNotification();
        closeDatabase();
    }
}

From source file:com.ichi2.anki.SyncClient.java

private void rebuildPriorities(long[] cardIds) {
    try {/*from www .j  av a 2s .  c om*/
        // TODO: Implement updateAllPriorities
        // deck.updateAllPriorities(true, false);
        mDeck.updatePriorities(cardIds, null, false);
    } catch (SQLException e) {
        Log.e(AnkiDroidApp.TAG, "SQLException e = " + e.getMessage());
    }
}

From source file:com.ichi2.anki.SyncClient.java

private JSONObject bundleStats() {
    Log.i(AnkiDroidApp.TAG, "bundleStats");

    JSONObject bundledStats = new JSONObject();

    // Get daily stats since the last day the deck was synchronized
    Date lastDay = new Date(java.lang.Math.max(0, (long) (mDeck.getLastSync() - 60 * 60 * 24) * 1000));
    Log.i(AnkiDroidApp.TAG, "lastDay = " + lastDay.toString());
    ArrayList<Long> ids = AnkiDatabaseManager.getDatabase(mDeck.getDeckPath()).queryColumn(Long.class,
            "SELECT id FROM stats WHERE type = 1 and day >= \"" + lastDay.toString() + "\"", 0);

    try {/* www  .  j  a  va2s  . c o  m*/
        Stats stat = new Stats(mDeck);
        // Put global stats
        bundledStats.put("global", Stats.globalStats(mDeck).bundleJson());
        // Put daily stats
        JSONArray dailyStats = new JSONArray();
        for (Long id : ids) {
            // Update stat with the values of the stat with id ids.get(i)
            stat.fromDB(id);
            // Bundle this stat and add it to dailyStats
            dailyStats.put(stat.bundleJson());
        }
        bundledStats.put("daily", dailyStats);
    } catch (SQLException e) {
        Log.i(AnkiDroidApp.TAG, "SQLException = " + e.getMessage());
    } catch (JSONException e) {
        Log.i(AnkiDroidApp.TAG, "JSONException = " + e.getMessage());
    }

    Log.i(AnkiDroidApp.TAG, "Stats =");
    Utils.printJSONObject(bundledStats, false);

    return bundledStats;
}

From source file:com.ichi2.anki.SyncClient.java

private void updateStats(JSONObject stats) {
    try {/*www .  j a v  a 2 s .  c o  m*/
        // Update global stats
        Stats globalStats = Stats.globalStats(mDeck);
        globalStats.updateFromJson(stats.getJSONObject("global"));

        // Update daily stats
        Stats stat = new Stats(mDeck);
        JSONArray remoteDailyStats = stats.getJSONArray("daily");
        int len = remoteDailyStats.length();
        for (int i = 0; i < len; i++) {
            // Get a specific daily stat
            JSONObject remoteStat = remoteDailyStats.getJSONObject(i);
            Date dailyStatDate = Utils.ordinalToDate(remoteStat.getInt("day"));

            // If exists a statistic for this day, get it
            try {
                Long id = AnkiDatabaseManager.getDatabase(mDeck.getDeckPath()).queryScalar(
                        "SELECT id FROM stats WHERE type = 1 AND day = \"" + dailyStatDate.toString() + "\"");
                stat.fromDB(id);
            } catch (SQLException e) {
                // If it does not exist, create a statistic for this day
                stat.create(Stats.STATS_DAY, dailyStatDate);
            }

            // Update daily stat
            stat.updateFromJson(remoteStat);
        }
    } catch (JSONException e) {
        Log.i(AnkiDroidApp.TAG, "JSONException = " + e.getMessage());
    }
}