Posts

Showing posts from March, 2012

Cannot drop index needed in a foreign key constraint

When you receive the message "MySQL Cannot drop index needed in a foreign key constraint" You have to drop the foreign key. Foreign keys in MySQL automatically create an index on the table (There was a SO Question on the topic). ALTER TABLE mytable DROP FOREIGN KEY mytable_ibfk_1; Then, try again! http://stackoverflow.com/questions/8482346/mysql-cannot-drop-index-needed-in-a-foreign-key-constraint

Share file between activites

1. Set this same shared user id in manifest <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.a" android:versionCode="1" android:versionName="1.0" android:sharedUserId="com.example.id"> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.b" android:versionCode="1" android:versionName="1.0" android:sharedUserId="com. example.id"> 2. Get another app’s context with createPackageContext() Context otherContext = context.createPackageContext("com.example.a", 0); AssetManager am = otherContext.getAssets(); http://joshzhchen.blogspot.com/2010/09/android-application-share-user-id.html http://stackoverflow.com/questions/5493396/how-to-reference-android-assets-across-packages

Using assets from any apk

Android allows a nice feature of adding your own files in the final apk package. These files are called “assets”. For adding assets to your project you simply add your files to the “prj_name/assets” directory. The files you add in the assets directory will be zipped in the final “apk” project, along with the executable-files and the other resources. One has two methods to access the asset files: use android.content.res.AssetManager Note that this will limit your asset files to 1Mb, at least for Android 1.5 release. use java.util.zip  This has no limitations to size, but will access all resources in the zip, so one has to filter the results. The implementations at a glance: android.content.res.AssetManager AssetManager am = getResources().getAssets(); // get the local asset manager InputStream is = am.open( asset ); // open the input stream for reading while ( true ) // do the reading { int count = is.read(buf, 0, MAX_BUF); // .. use the d...