Posts

Repair HFS+ when your BootCamp is error

Restart your Mac. As soon as it turns on, even before you hear it go bong, hold down Cmd+S. The system will boot showing a lot of text. If it doesn't and you see the Apple logo, you've waited too long. Reboot and try again. When at the prompt type  fsck -f . If changes are successfully made it will repeat the process then say "Modifications have been made". Then simply type in  reboot  and you should be able to partition your drive successfully. http://hints.macworld.com/article.php?story=20080120064811786

How to remove default/preloaded applications like browser,camera,contacts...

Suppose u have developed a new contact application which is much better than the preloaded contact application in android..so when u want to install it eclipse will throw u bunch of error saying "Please uninstall the contact application first by adb uninstall "package name". When u tried to do that...Alas...it did not work...saying FAILED The reason for this is that u don't have the root access and u have only read only access..So to change the access and remove the contacts(any application) follow the below instructions.. Start your emulator Execute "adb shell" in on terminal from SDK_ROOT/tool folder Mount your system folder with read/write permission mount -o remount,rw /dev/block/mtdblock3 /system Go to system/apps folder cd /system/apps Remove APK rm defaultapp.apk   Bingo Check your emulator.The default application is gone.Now u can install your application with eclipse. N.B.:This is required to remove the apps already present in emulator...If u want ...

Speed up SQLite insert

Using android.database.DatabaseUtils.InsertHelper class. Sample code: SQLiteDatabse db = getWriteableDatabase(); //use the db you would normally use for db.insert, and the "table_name" //is the same one you would use in db.insert() InsertHelper iHelp = new InsertHelper(db, "table_name"); //Get the indices you need to bind data to //Similar to Cursor.getColumnIndex("col_name"); int first_index = iHelp.getColumnIndex("first"); int last_index = iHelp.getColumnIndex("last"); try{ db.beginTransaction(); for(int i=0 ; i<num_things ; ++i) { //need to tell the helper you are inserting (rather than replacing) iHelp.prepareForInsert(); //do the equivalent of ContentValues.put("field","value") here iHelp.bind(first_index, thing_1); iHelp.bind(last_index, thing_2); //the db.insert() equilvalent iHelp.execute(); } db.setTransactionSuccessfu...

Set up ADB environment in Mac OSX

Open Terminal Type cd ~ this will take you to your home directory Type touch . profile this will create a hidden file named profile Type open - e . profile this will open the file you just created in TextEdit In the file, type export PATH = $ { PATH }:/ pathToTheAndroidSdkFolder / android - sdk - mac_86 / platform - tools Save file, close TextEdit, Quit Terminal, and Relaunch Terminal NOTE: By creating an environment variable you won't need to cd to the Android/tools folder every time you want to run ADB Reference:  http://esausilva.com/2010/10/02/how-to-set-up-adb-android-debug-bridge-in-mac-osx/

Get mimetype from header file

// return: jpeg, png, bmp, unknown public static String getMimeTypeFileByHeader(String realPath) { File f = new File(realPath); try { InputStream in = new FileInputStream(f); byte[] HEADERJPEG = new byte[] {(byte) 0xFF, (byte) 0xD8, (byte) 0xFF}; byte[] HEADERBMP = new byte[] { 0x42, 0x4d }; byte[] HEADERPNG = new byte[] { (byte) 0x89, 0x50, 0x4e }; byte[] header = new byte[3]; int h = in.read(header); if (h==3 && Arrays.equals(header, HEADERJPEG)) { return "jpeg"; } if (h==3 && Arrays.equals(header, HEADERPNG)) { return "png"; } byte[] header2 = new byte[2]; for (int i=0; i<2; i++) header2[i] = header[i]; if (Arrays.equals(header2, HEADERBMP)) { return "bmp"; } } catch (Throwable e) {} return "unknown...

Convert DateTime SQLite to GMT DateTime SQLite

static public String convertDateTimeToGMT(String in) { String out = in; SimpleDateFormat sdf = new SimpleDateFormat(Utility.getDBDateFormat()); Date iDate = null; try { iDate = sdf.parse(in); } catch (ParseException e) { Log.e(TAG, e.getMessage()); return in; } long newd = iDate.getTime() - sdf.getTimeZone().getRawOffset(); SimpleDateFormat osdf = new SimpleDateFormat(Utility.getDBDateFormat()); out = osdf.format(new Date(newd)); return out; }

Create JAR suitable for use with Dalvikvm

1. Create Helloworld.java: package org.apache; public class HelloWorld { public static void main(String[] args) { } } 2. Compile java: javac -d . -g Helloworld.java 3. Package Java Into a temporary jar jar -cvf Temp.jar * 4. Use DX to generate classes.dex from Temp.jar dx --dex --output=classes.dex Temp.jar 5. Use aapt to create new Jar (CmdLine.jar) suitable for use with Dalvikvm aapt add CmdLine.jar classes.dex 6. Push Jar to folder: adb shell     mount -o remount /system     exit adb push CmdLine.jar /system/framework/ 7. Restart: adb reboot