Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 73: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 74: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 75: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 76: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 77: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 78: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
package de.padde.cityguide; import java.io.File; import java.io.FileNotFoundException; import android.content.ContentProvider; import android.content.ContentUris; import android.content.ContentValues; import android.content.Context; import android.content.UriMatcher; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri; import android.os.Environment; import android.os.ParcelFileDescriptor; import android.text.TextUtils; import android.util.Log; public class CityGuideProvider extends ContentProvider { public static final String AUTHORITY = "de.padde.provider.cityguide"; public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/poi"); public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.padde.cityguide.poi"; public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.padde.cityguide.poi"; public static final String KEY_ID = "_id"; public static final String KEY_DATA = "_data"; public static final String KEY_LATITUDE = "latitude"; public static final String KEY_LONGITUDE = "longitude"; public static final String KEY_TYPE = "type"; public static final String KEY_DESCRIPTION = "description"; public static final int ID_COLUMN = 0; public static final int DATA_COLUMN = 1; public static final int LATITUDE_COLUMN = 2; public static final int LONGITUDE_COLUMN = 3; public static final int TYPE_COLUMN = 4; public static final int DESCRIPTION = 5; static final String DATABASE_PATH = "CityGuide"; static final File EXTERNAL_STORAGE_DIRECTORY = Environment.getExternalStorageDirectory(); private static final String DATABASE_NAME = "cache.db"; private static final int DATABASE_VERSION = 1; private static final String POI_TABLE_NAME = "pois"; private static final int SINGLE_POI = 1; private static final int MULTI_POI = 2; private static boolean mIsInitializing = false; private static boolean useLocal = false; private static String dbPath = EXTERNAL_STORAGE_DIRECTORY + File.separator + DATABASE_PATH + File.separator + DATABASE_NAME; private static final UriMatcher mUriMatcher; private static DatabaseHelper mDBOpenHelper; private static SQLiteDatabase mDB = null; static { mUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); mUriMatcher.addURI(AUTHORITY, "poi", MULTI_POI); mUriMatcher.addURI(AUTHORITY, "poi/#", SINGLE_POI); } private static class DatabaseHelper extends SQLiteOpenHelper { public DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); if(EXTERNAL_STORAGE_DIRECTORY.canWrite()) { File destination = new File(EXTERNAL_STORAGE_DIRECTORY, DATABASE_PATH); if(!destination.exists()) { if(!destination.mkdirs()) { useLocal = true; dbPath = DATABASE_NAME; } } } else { useLocal = true; dbPath = DATABASE_NAME; } } public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE " + POI_TABLE_NAME + " (" + KEY_ID + " INTEGER PRIMARY KEY," + KEY_DATA + " TEXT," + KEY_LATITUDE + " INTEGER NOT NULL," + KEY_LONGITUDE + " INTEGER NOT NULL," + KEY_TYPE + " INTEGER NOT NULL," + KEY_DESCRIPTION + " TEXT" + ");"); } public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + POI_TABLE_NAME); onCreate(db); } public synchronized SQLiteDatabase getReadableDatabase() { if(useLocal) return super.getReadableDatabase(); if (mDB != null && mDB.isOpen()) return mDB; if (mIsInitializing) throw new IllegalStateException("getReadableDatabase called recursively"); try { return getWritableDatabase(); } catch (SQLiteException e) { Log.e("DatabaseHelper", "Couldn't open " + DATABASE_NAME + " for writing (will try read-only):", e); } SQLiteDatabase db = null; try { mIsInitializing = true; db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READONLY); if (db.getVersion() != DATABASE_VERSION) { throw new SQLiteException("Can't upgrade read-only database from version " + db.getVersion() + " to " + DATABASE_VERSION + ": " + dbPath); } onOpen(db); mDB = db; return mDB; } finally { mIsInitializing = false; if (db != null && db != mDB) db.close(); } } public synchronized SQLiteDatabase getWritableDatabase() { if(useLocal) return super.getWritableDatabase(); if (mDB != null && mDB.isOpen() && !mDB.isReadOnly()) return mDB; if (mIsInitializing) throw new IllegalStateException("getWritableDatabase called recursively"); boolean success = false; SQLiteDatabase db = null; try { mIsInitializing = true; db = SQLiteDatabase.openOrCreateDatabase(dbPath, null); int version = db.getVersion(); if (version != DATABASE_VERSION) { db.beginTransaction(); try { if (version == 0) onCreate(db); else onUpgrade(db, version, DATABASE_VERSION); db.setVersion(DATABASE_VERSION); db.setTransactionSuccessful(); } finally { db.endTransaction(); } } onOpen(db); success = true; return db; } finally { mIsInitializing = false; if (success) { if (mDB != null) { try { mDB.close(); } catch (Exception e) {} } mDB = db; } else if (db != null) db.close(); } } } public boolean onCreate() { mDBOpenHelper = new DatabaseHelper(getContext()); mDB = mDBOpenHelper.getWritableDatabase(); return (mDB == null) ? false : true; } public String getType(Uri uri) { switch (mUriMatcher.match(uri)) { case SINGLE_POI: return CONTENT_ITEM_TYPE; case MULTI_POI: return CONTENT_TYPE; default: throw new IllegalArgumentException("Unsupported URI: " + uri); } } public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); qb.setTables(POI_TABLE_NAME); if(mUriMatcher.match(uri) == SINGLE_POI) qb.appendWhere(KEY_ID + "=" + uri.getPathSegments().get(1)); String orderBy = sortOrder; if (TextUtils.isEmpty(sortOrder)) orderBy = KEY_TYPE; SQLiteDatabase db = mDBOpenHelper.getReadableDatabase(); Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy); c.setNotificationUri(getContext().getContentResolver(), uri); return c; } public Uri insert(Uri uri, ContentValues values) { if(values == null) throw new SQLException("Failed to insert row into " + uri + ": ContentValues is null"); if(!isValid(values)) throw new SQLException("Failed to insert row into " + uri); SQLiteDatabase db = mDBOpenHelper.getWritableDatabase(); long rowId = db.insert(POI_TABLE_NAME, "NULL", values); if (rowId > 0) { Uri newUri = ContentUris.withAppendedId(CONTENT_URI, rowId); getContext().getContentResolver().notifyChange(newUri, null); return newUri; } throw new SQLException("Failed to insert row into " + uri); } public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { if(values == null) throw new SQLException("Failed to update row in " + uri + ": ContentValues is null"); SQLiteDatabase db = mDBOpenHelper.getWritableDatabase(); int count = 0; String id; switch (mUriMatcher.match(uri)) { case MULTI_POI: count = db.update(POI_TABLE_NAME, values, selection, selectionArgs); break; case SINGLE_POI: id = uri.getPathSegments().get(1); count = db.update(POI_TABLE_NAME, values, KEY_ID + "=" + id + (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""), selectionArgs); break; default: throw new IllegalArgumentException("Unknown URI " + uri); } getContext().getContentResolver().notifyChange(uri, null); return count; } public int delete(Uri uri, String selection, String[] selectionArgs) { SQLiteDatabase db = mDBOpenHelper.getWritableDatabase(); int count = 0; switch (mUriMatcher.match(uri)) { case MULTI_POI: count = db.delete(POI_TABLE_NAME, selection, selectionArgs); break; case SINGLE_POI: String id = uri.getPathSegments().get(1); count = db.delete(POI_TABLE_NAME, KEY_ID + "=" + id + (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""), selectionArgs); break; default: throw new IllegalArgumentException("Unknown URI " + uri); } getContext().getContentResolver().notifyChange(uri, null); return count; } public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException { if (mUriMatcher.match(uri) != SINGLE_POI) throw new IllegalArgumentException("openFile not supported for directories"); try { String id = uri.getPathSegments().get(1); ContentValues values = new ContentValues(); values.put(KEY_DATA, EXTERNAL_STORAGE_DIRECTORY + File.separator + DATABASE_PATH + File.separator + "img"+ id +".png"); update(uri,values,new String(KEY_ID+"="+id),null); return openFileHelper(uri, mode); } catch (FileNotFoundException e) { throw new FileNotFoundException(); } } private boolean isValid(ContentValues v) { String errorcode = ""; if(!v.containsKey(KEY_LATITUDE)) errorcode += "Missing " + KEY_LATITUDE + " value in ContentValues"; if(!v.containsKey(KEY_LONGITUDE)) errorcode += "Missing " + KEY_LONGITUDE + " value in ContentValues"; if(!v.containsKey(KEY_TYPE)) errorcode += "Missing " + KEY_TYPE + " value in ContentValues"; if(errorcode.length() != 0) Log.e("CityGuideProvider", errorcode); return (errorcode.length() == 0) ? true : false; } }