FIT2081 Lecture Notes - Lecture 7: Asteroid Family

148 views4 pages
!"#"$"%&
'(&%%&)#*"++,("(-.)#"*)&/(0./(12+#*3+&(#"$+&%
4.(-/&"#&(#"$+&(*)(5$6(12%#(5&0*)&(70./(&89:
;2)5&/(SHAPES_TABLE_CREATE<
SchemeShapes.Shape.ID + " INTEGER PRIMARY KEY
AUTOINCREMENT NOT NULL, "
PRIMARY KEY '(*5&)#*0*&/(0./(#=&(/.>
§
AUTOINCREMENT '(&"-=(#*1&()&>(/.>("55&5(#.(#"$+&6(#=&(
%,%#&1(>*++(8&)&/"#&("()&>(2)*?2&(@!(0./(#="#(/.>
§
§
B("++(.#=&/(#"$+&(-.+21)%(#.($&(*)-+25&5(")5(-.//&%3.)5*)8(C"+2&%
D8E(SchemeShapes.Shape.SHAPE_NAME + " TEXT, " F
§
4.(?2&/,(5$6(2%&(SQLiteQueryBuilder
SQLiteQueryBuilder.query(db, projection,
selection, selectionArgs, groupBy, having,
sortOrder)
§
G
SQLiteOpenHelper
H*C&%($"%*-(.3&/"#*.)%(#.("--&%%(")5(1")*32+"#&(5"#"
G
I00&/%(5"#"$"%&(#.("33
G
onCreate(SQLiteDatabase db) {
Db.execSQL(SHAPES_TABLE_CREATE) }
JKL(%#"#&1&)#(#.(-/&"#&(#"$+&(*)(5$
§
@)C.M&5(.)+,(*0(#=&(5$(,.2(="C&(3/.C*5&5(5.&%)N#(,&#(&O*%#
4"$+&(*%(-/&"#&5(0./(2%(")5(%#./&5(+.-"++,
G
super -#./:(super (context, String DB_NAME, factory null,
int DB_VERSION)
factory *0().#()2++(-/&"#&%("(%3&-*"+(-2/%./
G
onUpgrade(SQLiteDatabase db,
int [old db ver], int [new db ver])
L"%#(P(3"/"1%(/&3/&%&)#(#=&(C&/%*.)%(.0(#=&(5$(#="#(#=&(
3/.8/"11&/(>*%=&%(#.(235"#&(0/.1(")5(#.
§
@)C.M&5(*0(#=&(-2//&)#(5$(C&/%*.)(*%(+.>&/(#=")(#=&(.)&(%#"#&5(*)(#=&(
-+"%%(7*E&E(DB_VERSION C"+2&(="%($&&)(*)-/&1&)#&56(%.(5$()&&5%(#.(
$&(235"#&59
Q35"#&%(5$(#.()&>(C&/%*.)(%3&-*0*&5(*)(DB_VERSION
RE
S+%.(5/.3%T"55%(./(1.5*0*&%(#"$+&%("--(#.()&>(5$(C&/
PE
G
getWritableDatabase
I3&)%("(5"#"$"%&(0./(&5*#*)8(7"556(235"#&6(5&+&#&9
G
getReadableDatabase
G
rawQuery(String, String[])
3"/"1R:SQL query #="#(+&#%(1&#=.5(M).>(>="#(JKL(-.11")5(#.(
-"//,(.2#
!&0*)&%(/.>%(#="#(#=&(2%&/(>")#%(#.(-=..%&
§
D8E("select * from " + SHAPES_TABLE_NAME"
§
3"/"1P:(%&+&-#*.)("/821&)#%
'(+*%#(.0("/8%(.0(-.)5*#*.)%TC"+2&%(#.($&(-.)%*5&/&5(>=&)(%&"/-=*)8(
#=/.28=(5$(0./(/.>(*)(#"$+&(#="#(02+0*+%(%"*5(-.)5*#*.)%
U&#2/)%("(Cursor .$A&-#(.0(V6R(./(1./&(/.>%(7"(%2$%&#(.0(.2/(/.>%9(
#="#("-#%("%(#=&(-.)#"*)&/(0./(#=&(3.*)#&/(#.(>=&/&(#=&(5"#"(>"%(
+.-"#&5
G
query(SHAPES_TABLE_NAME, columns, String where, String[]
args, groupBy, having, orderBy)
Q%&5(#.(-=&-M(#"$+&(0./(/.>(>*#=(-.+21)()"1&(where
G
insert(SHAPES_TABLE_NAME, nullColumnHack, contentValues)
U&?2*/&%(5"#"(#.($&(3"-M&5(*)#.("(W.)#&)#X"+2&%(5"#"(%#/2-#2/&
!.&%)N#(/&#2/)("),#=*)8
ContentValues
'(%3&-*"+(-.)#"*)&/(0./(#=&(M&,Y3"*/(C"+2&%(>&()&&5(*)(
./5&/(#.(%&+&-#(#=&(/.>(")5(-.+21)(.0(#=&(+.-"#*.)(.0(#=&(
5"#"
Z&+3%(2%(*5&)#*0,(+.-"#*.)(.0(#=&(5"#"(>&(>*%=(#.(*)%&/#[
contentValues.put
[
§
nullColumnHack Y%3&-*"+(-"%&6(*0(,.2(>")#(%.1&(-.+%(./(%.1&(/.>%(
)2++E(!&0"2+#(C"+2&(*%(nullE
G
delete(SHAPES_TABLE_NAME, String where, String[] args)
U&#2/)%(")(*)#&8&/(*)5*-"#*)8(#=&()21$&/(.0(/.>%("00&-#&5
4.(1.5*0,($..+&")(#="#(/&#2/)%("#(#=&(&)5(.0(1&#=.5
§
G
update(SHAPES_TABLE_NAME, contentValues, where, args)
U&#2/)%(")(*)#&8&/(*)5*-"#*)8(#=&()21$&/(.0(/.>%("00&-#&5
4.(1.5*0,($..+&")(#="#(/&#2/)%("#(#=&(&)5(.0(1&#=.5
§
G
Cursor
CursorAdapter(Context, Cursor, FragmentManager fMgr)
super(Context, Cursor, int flags)
G
fMgr Y#=*%(*)%#")-&()&&5&5(%.(#=&(W2/%./S5"3#&/(M).>%(>=*-=(
1")"8&/(*#()&&5%(#.(2%&
G
dbHelper = new ShapesDbHelper(myContext);
G
\#>)("(5$(Cursor ")5("(Fragment 7%3&-*0*-"++,(#=&(Views *)(*#9G
W.)#"*)%(#=&(&C&)#(=")5+&/%(0./(&C&)#%(0./(&"-=(*#&1(*)(#=&(-.))&-#&5(
Views
G
getItem(int position)
H&#%(#=&(5"#"(*#&1("%%.-*"#&5(>*#=(#=&(%3&-*0*&5(3.%*#*.)(*)(#=&(
5"#"(%&#
IC&//*55&)
U&#2/)%(")(Object 2%*)8(super.getItem(position)
G
newView(Context, Cursor, ViewGroup)
return
LayoutInflater.from(context).inflate(R.layout.
__, ViewGroup, boolean attachToRoot)
]"M&%("()&>(C*&>(#.(=.+5(#=&(5"#"(3.*)#&5(#.($,(-2/%./
7*E&E(*)0+"#&%(#=&(View .0(.)&(%*)8+&(/.>9
G
bindView(View, Context, Cursor)
\*)5%(")(&O*%#*)8(C*&>(#.(#=&(5"#"(3.*)#&5(#.($,(-2/%./
^*)5%(0*&+5%(#.(3.32+"#&(*)(*)0+"#&5(#&13+"#&(7-2/%./(*)(#=*%(
-"%&9
§
H/"$%("++(C*&>%6(#=&)(3.32+"#&%(>*#=(5"#"(0/.1(-2/%./
§
DO#/"-#(3/.3&/#*&%(0/.1(-2/%./(2%*)8(
cursor.getString()
§
_.32+"#&%(0*&+5%(>*#=(&O#/"-#&5(3/.3&/#*&%
§
G
getCount
H&#%()21$&/(.0(/.>%(*)(-2/%./
G
!"#"$"%&`R`J#25&)#
CustomView ;X*&>J="3&%<
W#./(%&#%(23(%.1&(3"*)#(")5(-.+.2/(5&0"2+#%G
DO#&)5%(View 7*E&E("(%2$-+"%%9G
onDraw
G
'(5/">%(.)#.(#=&(View's $"-M8/.2)5
IC&//*55&)(1&#=.5
Canvas
Z.+5%(#=&(a5/">a(-"++%
G
Paint
Z.+5%(#=&(%#,+&(")5(-.+.2/(*)0.("$.2#(=.>(#.(5/">(8&.1&#/*&%6(
#&O#(")5($*#1"3%
G
drawCircle(float cx, float cy, float radius,
G
Paint paint)
!/">%(#=&(%3&-*0*&5(-*/-+&( 2%*)8(#=&(%3&-*0*&5(3"*)#
Paint -")()&C&/($&()2++6(-.)#"*)%(#=&(%#,+&
§
drawRect(float left, float top, float right, float
bottom, Paint paint)
!/">%(#=&(%3&-*0*&5(/&-#")8+&(2%*)8(#=&(%3&-*0*&5(3"*)#
Paint -")()&C&/($&()2++6(-.)#"*)%(#=&(%#,+&
§
G
invalidate
4&++%(S)5/.*5(#.("33+,(-=")8&%(#.(X*&>%("%(%..)("%(#=&()&O#(
"C"*+"$+&(3.*)#(*)(#*1&("++.>%(0./(*#
@)%#&"5(.0(2%*)8()./1"+(1&#=.5(7*)(#=*%(-"%&(onDraw()9(%*)-&(
&O3&)%*C&(2%"8&(.0(#*1&
G
Week$7
42&%5",6( Pb(]",(PVRc
RR:VP
Unlock document

This preview shows page 1 of the document.
Unlock all 4 pages and 3 million more documents.

Already have an account? Log in

Document Summary

To create table in db, must define (for eg): Autoincrement = each time new row added to table, the system will generate a new unique id for that row. Not null = if row is null, reject. + all other table columns to be included and corresponding values. Gives basic operations to access and manipulate data. Invoked only if the db you have provided doesn"t yet exist. Table is created for us and stored locally super ctor: super (context, string db_name, factory null, int db_version) factory if not null creates a special cursor onupgrade(sqlitedatabase db, int [old db ver], int [new db ver]) Last 2 params represent the versions of the db that the programmer wishes to update from and to. Invoked if the current db version is lower than the one stated in the class (i. e. db_version value has been incremented, so db needs to be updated) Updates db to new version specified in db_version.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents