Due to the project requirements, in the System multimedia management database storage image files in the table need to add a new field, source code in: Project \packages\providers\mediaprovider\ Mediaprovider.java, in the Updatedatabase () method, you will find that the images table is a view created by files, and a field is added to the creation of files as follows:
..... db.execsql ("CREATE TABLE files (" + "_id INTEGER PRIMARY KEY autoincrement," + "_data TEXT," +//This can is null for playlists "_size INTEGER," + "Format integer," + "parent Integer," + "date_added Integer," + "Date_modified INTEGER," + "Mime_type text," + "title text," + "description text," + "_display_name text," +//F or images "picasa_id TEXT," + "orientation INTEGER," + For images and video "latitude double," + "longitude double," + "Datetaken Integer," + "Mini_thumb_magic Integer," + "bucket _id TEXT, "+ "Bucket_display_name TEXT," + "isprivate INTEGER," + "is_upload INTEGER, "+//----------new Field//For audio" Title_key TEXT, "+ "artist_id Integer," + "album_id Integer," + "composer TEXT," + "Track integer," + "year INTEGER CHECK (year!=0)," + "Is_ Ringtone integer, "+" Is_music Integer, "+" Is_alarm Integer, "+ "Is_notification Integer," + "Is_podcast Integer," + "Is_doorbel L Integer, "+" Is_auto_alarm Integer, "+" album_artist TEXT, "+ For audio and video "duration integer," + "bookmark Integer," +For video "artist text," + "album text," + "Resolu tion text, "+" tags text, "+" category text, "+" Lang Uage text, "+" Mini_thumb_data text, "+//For playlists "Name TEXT," +//Media_type is used by the emulate the old// Images, Audio_meta, videos and audio_playlist tables. "Media_type INTEGER," +//Value of _id from the old media table. Used-updating other tables during database upgrade. "old_id Integer," + "isaccurateduration integer" + ");
This field is also added when the images view is created
private static final String Image_columns = "_data,_size,_display_name,mime_type,title,date_added," + "Date_ Modified,description,picasa_id,isprivate,latitude,longitude, "+ " datetaken,orientation,mini_thumb_magic, Bucket_id,bucket_display_name, "+ " width,height,is_upload ";
After compiling, put the APK push to System/priv-app next look and find a running error:
03-01 09:31:24.367:e/androidruntime (1065): Java.lang.RuntimeException:Unable to get Provider Com.android.providers.media.MediaProvider:android.database.sqlite.SQLiteException:no such Column:drm_content_uri (Code 1): While Compiling:create VIEW Audio_meta as SELECT _id,_data,_display_name,_size,mime_type,date_added,is_drm, Date_modified,title,title_key,duration,artist_id,composer,album_id,track,year,is_ringtone,is_music,is_alarm,is _notification,is_podcast,is_doorbell,is_auto_alarm,bookmark,album_artist,drm_content_uri,drm_offset,drm_ Datalen,drm_rights_issuer,drm_content_name,drm_content_description,drm_content_vendor,drm_icon_uri,drm_method, Title_pinyin_key from files WHERE media_type=2;
03-01 09:31:24.367:e/androidruntime (1065): at Android.app.ActivityThread.installProvider (activitythread.java:5011 )
03-01 09:31:24.367:e/androidruntime (1065): at Android.app.ActivityThread.installContentProviders ( activitythread.java:4582)
03-01 09:31:24.367:e/androidruntime (1065): at Android.app.ActivityThread.handleBindApplication ( activitythread.java:4522)
03-01 09:31:24.367:e/androidruntime (1065): at android.app.activitythread.access$1500 (ActivityThread.java:151)
03-01 09:31:24.367:e/androidruntime (1065): at Android.app.activitythread$h.handlemessage (ActivityThread.java:1381 )
03-01 09:31:24.367:e/androidruntime (1065): at Android.os.Handler.dispatchMessage (handler.java:110)
03-01 09:31:24.367:e/androidruntime (1065): at Android.os.Looper.loop (looper.java:193)
03-01 09:31:24.367:e/androidruntime (1065): at Android.app.ActivityThread.main (activitythread.java:5292)
03-01 09:31:24.367:e/androidruntime (1065): at Java.lang.reflect.Method.invokeNative (Native Method)
03-01 09:31:24.367:e/androidruntime (1065): at Java.lang.reflect.Method.invoke (method.java:515)
03-01 09:31:24.367:e/androidruntime (1065): at Com.android.internal.os.zygoteinit$methodandargscaller.run ( zygoteinit.java:824)
03-01 09:31:24.367:e/androidruntime (1065): at Com.android.internal.os.ZygoteInit.main (zygoteinit.java:640)
03-01 09:31:24.367:e/androidruntime (1065): at Dalvik.system.NativeStart.main (Native Method)
03-01 09:31:24.367:e/androidruntime (1065): caused by:android.database.sqlite.SQLiteException:no such column:drm_ Content_uri (Code 1):, while Compiling:create VIEW Audio_meta as SELECT _id,_data,_display_name,_size,mime_type,date_ad Ded,is_drm,date_modified,title,title_key,duration,artist_id,composer,album_id,track,year,is_ringtone,is_music, Is_alarm,is_notification,is_podcast,is_doorbell,is_auto_alarm,bookmark,album_artist,drm_content_uri,drm_offset , Drm_datalen,drm_rights_issuer,drm_content_name,drm_content_description,drm_content_vendor,drm_icon_uri,drm_ Method,title_pinyin_key from files WHERE media_type=2;
03-01 09:31:24.367:e/androidruntime (1065): at Android.database.sqlite.SQLiteConnection.nativePrepareStatement ( Native Method)
03-01 09:31:24.367:e/androidruntime (1065): at Android.database.sqlite.SQLiteConnection.acquirePreparedStatement ( sqliteconnection.java:893)
03-01 09:31:24.367:e/androidruntime (1065): at Android.database.sqlite.SQLiteConnection.prepare ( sqliteconnection.java:504)
03-01 09:31:24.367:e/androidruntime (1065): at Android.database.sqlite.SQLiteSession.prepare (Sqlitesession.java : 588)
03-01 09:31:24.367:e/androidruntime (1065): at Android.database.sqlite.sqliteprogram.<init> ( SQLITEPROGRAM.JAVA:58)
03-01 09:31:24.367:e/androidruntime (1065): at Android.database.sqlite.sqlitestatement.<init> ( SQLITESTATEMENT.JAVA:31)
03-01 09:31:24.367:e/androidruntime (1065): at ANDROID.DATABASE.SQLITE.SQLITEDATABASE.EXECUTESQL ( sqlitedatabase.java:1697)
03-01 09:31:24.367:e/androidruntime (1065): at Android.database.sqlite.SQLiteDatabase.execSQL (Sqlitedatabase.java : 1628)
03-01 09:31:24.367:e/androidruntime (1065): at Com.android.providers.media.MediaProvider.updateViewAfterNewTable ( mediaprovider.java:7404)
03-01 09:31:24.367:e/androidruntime (1065): at Com.android.providers.media.MediaProvider.updateDatabase ( mediaprovider.java:2264)
03-01 09:31:24.367:e/androidruntime (1065): at com.android.providers.media.mediaprovider.access$1200 ( mediaprovider.java:126)
03-01 09:31:24.367:e/androidruntime (1065): at Com.android.providers.media.mediaprovider$databasehelper.oncreate ( mediaprovider.java:493)
03-01 09:31:24.367:e/androidruntime (1065): at Android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked ( sqliteopenhelper.java:252)
03-01 09:31:24.367:e/androidruntime (1065): at Android.database.sqlite.SQLiteOpenHelper.getReadableDatabase ( sqliteopenhelper.java:188)
03-01 09:31:24.367:e/androidruntime (1065): at Com.android.providers.media.MediaProvider.query (Mediaprovider.java : 2796)
03-01 09:31:24.367:e/androidruntime (1065): at Com.android.providers.media.MediaProvider.attachVolume ( mediaprovider.java:6391)
03-01 09:31:24.367:e/androidruntime (1065): at Com.android.providers.media.MediaProvider.onCreate ( mediaprovider.java:889)
03-01 09:31:24.367:e/androidruntime (1065): at Android.content.ContentProvider.attachInfo (Contentprovider.java : 1638)
03-01 09:31:24.367:e/androidruntime (1065): at Android.content.ContentProvider.attachInfo (Contentprovider.java : 1609)
03-01 09:31:24.367:e/androidruntime (1065): at Android.app.ActivityThread.installProvider (activitythread.java:5008 )
Well, there's No field "Is_upload" in Files, so why? Repeated reading of the Code of Updatedatabase (), found that there is such a paragraph:
Db.execsql ("INSERT OR REPLACE into files2 select" + getallcolumns () + "from files;"); Db.execsql ("DROP TABLE files;"); Db.execsql ("ALTER TABLE files2 RENAME to files;");
Originally, the source of files is Files2, then add the "is_upload" field when Files2 is created, and add the field in Getallcolumns ().
Compile validation, ok!
Android source, add a field to the System multimedia database