1. A few days ago someone asked me to remember when she washed the hair, and then remember to remind her, so complex things, I had to think of something to help me, and then this is 2. Just look at the effect.
Initial situation
Click on one as a marker
Click once again to delete
3. Here also to thank the predecessors of the Code as a reference, after all, have not written about the calendar aspects of things, others did write well, I added on the original basis of database operations and other supplements to complete their actual needs, as a respect for the first to give the original author's connection
This is the –>http://blog.csdn.net/airsaid/article/details/52139045.
4. Then paste out the code about the database operation, give everyone as a reference
Databasehelper. Java this is the part about simple database operations
PackageCom.xugongming38.editcalendar.utils;ImportAndroid.content.Context;ImportAndroid.database.sqlite.SQLiteDatabase;ImportAndroid.database.sqlite.SQLiteOpenHelper;/** * Created by Dell on 2017/5/18. * * Public class databasehelper extends sqliteopenhelper { Public Static FinalString create_diary =The CREATE Table Hair ("+"ID integer primary key autoincrement,"+"Content text");PrivateContext Mcontext; Public Databasehelper(context context, String name, Sqlitedatabase.cursorfactory factory,intVersion) {Super(context, name, Factory, version); Mcontext = context; }@Override Public void onCreate(Sqlitedatabase db) {Db.execsql (create_diary); }@Override Public void Onupgrade(Sqlitedatabase DB,intOldversion,intNewVersion) {Db.execsql ("drop table if exists Hair"); OnCreate (DB); }}
Datahelper. Java simplifies data manipulation interfaces, avoids direct manipulation of databases, does a layer of encapsulation, and advises readers to do the same, making the code clearer and easier to reuse
PackageCom.xugongming38.editcalendar.utils;ImportAndroid.content.ContentValues;ImportAndroid.content.Context;ImportAndroid.database.Cursor;ImportAndroid.database.sqlite.SQLiteDatabase;ImportJava.util.ArrayList;ImportJava.util.List;/** * Created by Dell on 2017/5/18. * * Public class datahelper { Public StaticDatabasehelper Mhelper; Public Static void deletedata2list(String content) {Sqlitedatabase dbdelete = Mhelper.getwritabledatabase (); Dbdelete.delete ("Hair","content =?",NewString[]{content}); } Public Static void adddata2list(String content) {Sqlitedatabase db = Mhelper.getwritabledatabase (); Contentvalues values =NewContentvalues (); Values.put ("Content", content); Db.insert ("Hair",NULL, values); Values.clear (); } Public StaticList<string>getdatalist(Context context) {if(mhelper==NULL) {Mhelper =NewDatabasehelper (Context,"Hair.db",NULL,1); } list<string> dataList =NewArraylist<> (); Sqlitedatabase sqlitedatabase = Mhelper.getwritabledatabase (); cursor cursor = Sqlitedatabase.query ("Hair",NULL,NULL,NULL,NULL,NULL,NULL);if(Cursor.movetofirst ()) {do {String content = cursor.getstring (Cursor.getcolumnindex ("Content")); Datalist.add (content); } while(Cursor.movetonext ()); } cursor.close ();returnDataList; }}
5. The full code section below gives GitHub address, welcome star, the level is limited, if necessary, welcome message discussion
This is my GitHub location –https://github.com/xugongming38/editcalendar
Android Custom can mark calendars