当前位置: 首页>>代码示例>>Java>>正文


Java SQLiteCantOpenDatabaseException类代码示例

本文整理汇总了Java中android.database.sqlite.SQLiteCantOpenDatabaseException的典型用法代码示例。如果您正苦于以下问题:Java SQLiteCantOpenDatabaseException类的具体用法?Java SQLiteCantOpenDatabaseException怎么用?Java SQLiteCantOpenDatabaseException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SQLiteCantOpenDatabaseException类属于android.database.sqlite包,在下文中一共展示了SQLiteCantOpenDatabaseException类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: existsDatabase

import android.database.sqlite.SQLiteCantOpenDatabaseException; //导入依赖的package包/类
private boolean existsDatabase()
{
	SQLiteDatabase database = null;
	boolean isExist = true;

	try
	{
		database = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY);
	}
	catch (SQLiteCantOpenDatabaseException e)
	{
		// No database
		Log.d("Database", "Database not found!");
		isExist = false;
	}
	finally
	{
		if ( database != null )
			database.close();
	}

	return isExist;
}
 
开发者ID:Mnkai,项目名称:OpenXiaomiScale,代码行数:24,代码来源:Database.java

示例2: if

import android.database.sqlite.SQLiteCantOpenDatabaseException; //导入依赖的package包/类
@NonNull
@VisibleForTesting
/*package*/ SQLiteDatabase getDatabase() {
    if (mInjectedDatabase != null) {
        return mInjectedDatabase;
    } else {
        try {
            return mDbHelper.getWritableDatabase();

        } catch (SQLiteCantOpenDatabaseException e) {
            CAT.e(e);

            // that's bad, delete the database and try again, otherwise users may get stuck in a loop
            new JobStorageDatabaseErrorHandler().deleteDatabaseFile(DATABASE_NAME);
            return mDbHelper.getWritableDatabase();
        }
    }
}
 
开发者ID:evernote,项目名称:android-job,代码行数:19,代码来源:JobStorage.java

示例3: open

import android.database.sqlite.SQLiteCantOpenDatabaseException; //导入依赖的package包/类
/**
 * open cache file
 * @param file
 */
public void open(File file, Resources resources, MapView map)
    throws SQLiteCantOpenDatabaseException
{
    mResources = resources;
    mMap = map;
    
    boolean exists = file.exists();
    
    mDB = SQLiteDatabase.openOrCreateDatabase(file, null);

    if(!exists)
    {
        mDB.execSQL(CREATE_CACHE_TABLE);
    }
}
 
开发者ID:Jules-,项目名称:terraingis,代码行数:20,代码来源:TileCache.java

示例4: throwSQLException

import android.database.sqlite.SQLiteCantOpenDatabaseException; //导入依赖的package包/类
public static void throwSQLException(android.database.SQLException exception)
    throws SQLException {

    if(exception instanceof SQLiteConstraintException) {
        throw new SQLIntegrityConstraintViolationException(exception);

    } else if(exception instanceof SQLiteCantOpenDatabaseException ||
        exception instanceof SQLiteDatabaseCorruptException ||
        exception instanceof SQLiteAccessPermException) {

        throw new SQLNonTransientException(exception);
    }
    throw new SQLException(exception);
}
 
开发者ID:requery,项目名称:requery,代码行数:15,代码来源:BaseConnection.java

示例5: hasEnabledAccounts

import android.database.sqlite.SQLiteCantOpenDatabaseException; //导入依赖的package包/类
public boolean hasEnabledAccounts() {
	SQLiteDatabase db = this.getReadableDatabase();
	Cursor cursor = db.rawQuery("select count(" + Account.UUID + ")  from "
			+ Account.TABLENAME + " where not options & (1 <<1)", null);
	try {
		cursor.moveToFirst();
		int count = cursor.getInt(0);
		cursor.close();
		return (count > 0);
	} catch (SQLiteCantOpenDatabaseException e) {
		return true; // better safe than sorry
	}
}
 
开发者ID:juanignaciomolina,项目名称:txtr,代码行数:14,代码来源:DatabaseBackend.java

示例6: storeNotification

import android.database.sqlite.SQLiteCantOpenDatabaseException; //导入依赖的package包/类
public void storeNotification(long time, String title, String subtitle, String text, Bitmap icon)
{
	ContentValues values = new ContentValues();
	values.put("PostTime", time);
	values.put("Title", title);
	values.put("Subtitle", subtitle);
	values.put("Text", text);

	if (icon == null)
		values.put("Icon", (byte[]) null);
	else
	{
		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
		icon.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
		values.put("Icon", byteArrayOutputStream.toByteArray());
	}

	try
	{
		getWritableDatabase().insert("notifications", null, values);
	}
	catch (SQLiteCantOpenDatabaseException e)
	{
		Timber.e(e, "Database open exception!");
		e.printStackTrace();
	}
}
 
开发者ID:matejdro,项目名称:PebbleNotificationCenter-Android,代码行数:28,代码来源:NotificationHistoryStorage.java

示例7: onCreate

import android.database.sqlite.SQLiteCantOpenDatabaseException; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public final void onCreate() {		
	Log.d(TAG, "WirelessLoggerService created");
	super.onCreate();

	final Notification note = new Notification(R.drawable.icon_greyed_25x25, getString(R.string.notification_caption), System.currentTimeMillis());
	final Intent i = new Intent(this, HostActivity.class);
	i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);
	final PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0);
	note.setLatestEventInfo(this, getString(R.string.app_name), getString(R.string.notification_caption), pi);
	note.flags|=Notification.FLAG_NO_CLEAR;

	//Notification note = new Notification(R.drawable.icon_greyed_25x25, getString(R.string.notification_caption), System.currentTimeMillis());
	//note.flags |= Notification.FLAG_NO_CLEAR;
	startForeground(NOTIFICATION_ID, note);

	// get shared preferences
	prefs = PreferenceManager.getDefaultSharedPreferences(this);

	if (!prefs.getString(Preferences.KEY_WIFI_CATALOG_FILE, Preferences.VAL_WIFI_CATALOG_FILE).equals(Preferences.VAL_WIFI_CATALOG_NONE)) {
		final String catalogPath = prefs.getString(Preferences.KEY_WIFI_CATALOG_FOLDER,
				getApplicationContext().getExternalFilesDir(null).getAbsolutePath() + File.separator + Preferences.WIFI_CATALOG_SUBDIR)
				+ File.separator + prefs.getString(Preferences.KEY_WIFI_CATALOG_FILE, Preferences.VAL_WIFI_CATALOG_FILE);

		try {
			mRefDb = SQLiteDatabase.openDatabase(catalogPath, null, SQLiteDatabase.OPEN_READONLY);
		} catch (final SQLiteCantOpenDatabaseException ex) {
			Log.e(TAG, "Can't open wifi catalog database @ " + catalogPath);
			mRefDb = null;
		}
	} else {
		Log.w(TAG, "No wifi catalog selected. Can't compare scan results with openbmap dataset.");
	}

	/*
	 * Setting up database connection
	 */
	mDataHelper = new DataHelper(this);

	registerWakeLocks();

	registerPhoneStateManager();

	registerWifiManager();

	initBlacklists();
}
 
开发者ID:saintbyte,项目名称:openbmap,代码行数:49,代码来源:WirelessLoggerService.java

示例8: displayRecord

import android.database.sqlite.SQLiteCantOpenDatabaseException; //导入依赖的package包/类
/**
 * @param wifi
 */
private void displayRecord(final WifiRecord wifi) {

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    if (wifi == null) {
        Log.e(TAG, "Wifi argument was null");
        return;
    }

    if (!prefs.getString(Preferences.KEY_CATALOG_FILE, Preferences.VAL_CATALOG_NONE).equals(Preferences.VAL_CATALOG_NONE)) {
        // Open catalog database
        final String file = prefs.getString(Preferences.KEY_WIFI_CATALOG_FOLDER,
                this.getExternalFilesDir(null).getAbsolutePath() + File.separator + Preferences.CATALOG_SUBDIR)
                + File.separator + prefs.getString(Preferences.KEY_CATALOG_FILE, Preferences.VAL_CATALOG_FILE);
        try {
            final SQLiteDatabase mCatalog = SQLiteDatabase.openDatabase(file, null, SQLiteDatabase.OPEN_READONLY);
            Cursor cur = null;
            cur = mCatalog.rawQuery("SELECT _id, manufactor FROM manufactors WHERE "
                            + "(bssid = ?) LIMIT 1",
                    new String[]{wifi.getBssid().replace(":", "").replace("-", "").substring(0, 6).toUpperCase()});

            if (cur.moveToFirst()) {
                final String manufactor = cur.getString(cur.getColumnIndex("manufactor"));
                tvManufactor.setText(manufactor);
            }
            cur.close();
        } catch (SQLiteCantOpenDatabaseException e1) {
            Log.e(TAG, e1.getMessage());
            Toast.makeText(this, getString(R.string.error_opening_wifi_catalog), Toast.LENGTH_LONG).show();
            return;
        } catch (SQLiteException e2) {
            Log.e(TAG, e2.getMessage());
            Toast.makeText(this, R.string.error_accessing_wifi_catalog, Toast.LENGTH_LONG).show();
            return;
        }
    }

    tvSsid.setText(wifi.getSsid() + " (" + wifi.getBssid() + ")");
    if (wifi.getCapabilities() != null)

    {
        tvCapabilities.setText(wifi.getCapabilities().replace("[", "\n["));
    } else

    {
        tvCapabilities.setText(getResources().getString(R.string.n_a));
    }

    final Integer freq = wifi.getFrequency();
    if (freq != null)

    {
        tvFrequency.setText(((WifiChannel.getChannel(freq) == null) ? getResources().getString(R.string.unknown) : WifiChannel.getChannel(freq))
                        + "  (" + freq + " MHz)");
    }

    if (wifi.getCatalogStatus().equals(CatalogStatus.NEW)) {
        ivIsNew.setImageResource(android.R.drawable.checkbox_on_background);
    } else {
        ivIsNew.setImageResource(android.R.drawable.checkbox_off_background);
    }
}
 
开发者ID:openbmap,项目名称:radiocells-scanner-android,代码行数:66,代码来源:WifiDetailsActivity.java

示例9: onCreate

import android.database.sqlite.SQLiteCantOpenDatabaseException; //导入依赖的package包/类
@Override
  public final void onCreate() {
      Log.d(TAG, "WirelessLoggerService created");
      super.onCreate();

      // get shared preferences
      prefs = PreferenceManager.getDefaultSharedPreferences(this);

      if (!prefs.getString(Preferences.KEY_CATALOG_FILE, Preferences.VAL_CATALOG_FILE).equals(Preferences.VAL_CATALOG_NONE)) {
          final String catalogPath = prefs.getString(Preferences.KEY_WIFI_CATALOG_FOLDER,
                  getApplicationContext().getExternalFilesDir(null).getAbsolutePath() + File.separator + Preferences.CATALOG_SUBDIR)
                  + File.separator + prefs.getString(Preferences.KEY_CATALOG_FILE, Preferences.VAL_CATALOG_FILE);

          if (!(new File(catalogPath)).exists()) {
              Log.w(TAG, "Selected catalog doesn't exist");
              mRefDb = null;
          } else {
              try {
                  mRefDb = SQLiteDatabase.openDatabase(catalogPath, null, SQLiteDatabase.OPEN_READONLY);
              } catch (final SQLiteCantOpenDatabaseException ex) {
                  Log.e(TAG, "Can't open wifi catalog database @ " + catalogPath);
                  mRefDb = null;
              }
          }
      } else {
          Log.w(TAG, "No wifi catalog selected. Can't compare scan results with openbmap dataset.");
      }

/*
       * Setting up database connection
 */
      mDataHelper = new DataHelper(this);

      registerWakeLocks();

      registerPhoneStateManager();

      registerWifiManager();

      initBlacklists();
  }
 
开发者ID:openbmap,项目名称:radiocells-scanner-android,代码行数:42,代码来源:WirelessLoggerService.java


注:本文中的android.database.sqlite.SQLiteCantOpenDatabaseException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。