If you think the Android project utexas-utilities listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.nasageek.utexasutilities;
/*fromwww.java2s.com*/import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteCursor;
import android.net.Uri;
import android.preference.PreferenceManager;
import java.io.IOException;
publicclass BuildingProvider extends ContentProvider {
private BuildingDatabase bdb;
publicstaticfinal Uri CONTENT_URI = Uri
.parse("content://com.nasageek.utexasutilities.buildingprovider");
@Override
publicint delete(Uri uri, String selection, String[] selectionArgs) {
return 0;
}
@Override
public String getType(Uri uri) {
return null;
}
@Override
public Uri insert(Uri uri, ContentValues values) {
bdb.addBuilding(values);
return null;
}
@Override
publicboolean onCreate() {
// V1 Initial building list
// V2 Added all garages, Belo, a few dorms I missed. Should be the
// entire official building list now
// V3 CLA - Liberal Arts Building
// V4 POB, GDC - POB is ACES but renamed, leave them both in there
// V5 Add INT, ESS, CTR, CS3, CS4, CRB, CCF; remove ESB, RAS, RRN;
// rename GIA to GIAC
if (PreferenceManager.getDefaultSharedPreferences(this.getContext()).getInt(
"buildingdbversion", 1) < 5) {
if (this.getContext().deleteDatabase("buildings")) {
PreferenceManager.getDefaultSharedPreferences(this.getContext())
.edit().putInt("buildingdbversion", 5).apply();
}
}
bdb = new BuildingDatabase(this.getContext());
try {
bdb.createDataBase(false);
} catch (IOException e) {
e.printStackTrace();
}
bdb.openDataBase();
return true;
}
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder) {
SQLiteCursor sqlc = (SQLiteCursor) bdb.query("buildings", projection, selectionArgs[0],
null, null, null, sortOrder);
return sqlc;
}
@Override
publicint update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
return 0;
}
}