Saturday, 3 June 2017

How to add a new contact programmatically in android?

We all know how to add a new contact to our android devices without programming right.
OK that’s a normal man’s use.
But what from a programmer’s view.




import java.util.ArrayList;
import android.app.Activity;
import android.content.ContentProviderOperation;
import android.content.ContentValues;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.provider.Contacts.People;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.widget.Toast;
public class AddContactDemo extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        addContact("Hardik","1234567890");
        addContact("Alex","5656215521");
        addContact("Kenedy","4545454545");
        addContact("Peter","9632587410");
        addContact("John","4561237890");
    }
   private void addContact(String name, String phone) {
        ContentValues values = new ContentValues();
        values.put(People.NUMBER, phone);
        values.put(People.TYPE, Phone.TYPE_CUSTOM);
        values.put(People.LABEL, name);
        values.put(People.NAME, name);
        Uri dataUri = getContentResolver().insert(People.CONTENT_URI, values);
        Uri updateUri = Uri.withAppendedPath(dataUri, People.Phones.CONTENT_DIRECTORY);
        values.clear();
        values.put(People.Phones.TYPE, People.TYPE_MOBILE);
        values.put(People.NUMBER, phone);
        updateUri = getContentResolver().insert(updateUri, values);
      }
}

Wednesday, 22 June 2016

Push existing project into Github


  • git init 
  • git add .
  • git commit -m "Initial commit" 
  • git remote add origin 
  • git push -f origin master 

The -f option on git push forces the push. 

If you don't use it, you'll see an error like this:To git@github.com:roseperrone/project.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'git@github.com:roseperrone/project.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first merge the remote changes (e.g., hint: 'git pull') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Friday, 5 February 2016

Copy SQLite database from assets folder

public class DatabaseManager extends SQLiteOpenHelper {

    // *************** Declare all the global variable *******************//
    private Context myContext;
    private String PACKAGE_NAME = "YOUR_PACKAGE_NAME";

    // path of your datbase
    private String DB_PATH = Environment.getDataDirectory() + "/data/"
            + PACKAGE_NAME + "/databases/";

    // the extension may be .sqlite or .db
    private static String DB_NAME = "YOUR_DATABASE_NAME";
    private static String DB_ASSETNAME = "YOUR_ASSET_DATABASE_NAME";
    public SQLiteDatabase myDataBase;
    private ContentValues contentValues;

    private Cursor cursor;
    private ArrayList> arrayList;
    private ArrayList array_list;
    private HashMap hashMap;

    private SimpleDateFormat dateformat, timeformat;

    public DatabaseManager(Context context) throws IOException {
        super(context, DB_NAME, null, 1);
        // this.myDataBase = getWritableDatabase();
        this.myContext = context;
        boolean dbexist = checkdatabase();
        if (dbexist) {
            // System.out.println("Database exists");
            opendatabase();
        } else {
            System.out.println("Database doesn't exist");
            createdatabase();
        }
    }

    public void createdatabase() throws IOException {
        boolean dbexist = checkdatabase();
        if (dbexist) {
            System.out.println(" Database exists.");
        } else {
            this.getReadableDatabase();
            try {
                copydatabase();

            } catch (IOException e) {
                throw new Error("Error copying database");
            }
        }
    }

    private boolean checkdatabase() {
        // SQLiteDatabase checkdb = null;
        boolean checkdb = false;
        try {
            String myPath = DB_PATH + DB_NAME;
            File dbfile = new File(myPath);
            // checkdb =
            // SQLiteDatabase.openDatabase(myPath,null,SQLiteDatabase.OPEN_READWRITE);
            checkdb = dbfile.exists();
        } catch (SQLiteException e) {
            System.out.println("Database doesn't exist.....");
        }
        return checkdb;
    }

    private void copydatabase() throws IOException {
        // Open your local db as the input stream
        InputStream myinput = myContext.getAssets().open(DB_ASSETNAME);

        // Path to the just created empty db
        // String out filename = DB_PATH + DB_NAME;

        // Open the empty db as the output stream
        OutputStream myoutput = new FileOutputStream(DB_PATH + DB_NAME);

        // transfer byte to input file to output file
        byte[] buffer = new byte[1024];
        int length;
        while ((length = myinput.read(buffer)) > 0) {
            myoutput.write(buffer, 0, length);
        }

        // Close the streams
        myoutput.flush();
        myoutput.close();
        myinput.close();

    }

    public void opendatabase() throws SQLException {
        // Open the database
        String mypath = DB_PATH + DB_NAME;
        myDataBase = SQLiteDatabase.openDatabase(mypath, null,
                SQLiteDatabase.OPEN_READWRITE);
    }

    @Override
    public synchronized void close() {
        if (myDataBase != null) {
            myDataBase.close();
        }
        super.close();
    }

    @Override
    public void onCreate(SQLiteDatabase db) {

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}

Monday, 30 November 2015

Volley Get and Post Method Example

//for get method

private JSONObject jObj;

private void volleyGetMethod() {


        JsonObjectRequest jsonObjReq = new JsonObjectRequest(Method.GET,

                YOUR_URL, null,
                new Response.Listener() {

                    @Override

                    public void onResponse(JSONObject response) {

                        try {


                            jObj = new JSONObject(response.toString());


// rest of your code here

                           

                        } catch (Exception e) {

                            e.printStackTrace();
                        }

                    }

                }, new Response.ErrorListener() {

            @Override

            public void onErrorResponse(VolleyError error) {

                // System.out.println(error.getMessage());


            }

        }) {

            /**

             * Passing some request headers
             */
            @Override
            public Map getHeaders() throws AuthFailureError {
                HashMap headers = new HashMap();
                headers.put("Content-Type", "application/json; charset=utf-8");
                return headers;
            }

        };

        jsonObjReq.setRetryPolicy(new DefaultRetryPolicy(60000,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

        // Adding request to request queue

        Volley.newRequestQueue(activity).add(jsonObjReq);
    }


// for post method

private void volleyPostMethod() {

JSONObject obj = new JSONObject();


try {


obj.put("number", "");

                        //  add other parameter here..

} catch (Exception e) {


}


JsonObjectRequest jsonObjReq = new JsonObjectRequest(Method.POST,

YOUR_URL, obj,
new Response.Listener() {

@Override

public void onResponse(JSONObject response) {

try {


System.out.println("res -- " + response.toString());


JSONObject jsonObject = new JSONObject(response

.toString());

// rest of your code here

} catch (Exception e) {

e.printStackTrace();

}


activity.runOnUiThread(new Runnable() {


@Override

public void run() {

// rest of your code here


}
});

}

}, new Response.ErrorListener() {

@Override

public void onErrorResponse(VolleyError error) {

// show Dialog for error

}

}) {

/**

* Passing some request headers
*/
@Override
public Map getHeaders() throws AuthFailureError {
HashMap headers = new HashMap();
headers.put("Content-Type", "application/json; charset=utf-8");
return headers;
}

};

jsonObjReq.setRetryPolicy(new DefaultRetryPolicy(60000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

// Adding request to request queue

Volley.newRequestQueue(activity).add(jsonObjReq);

}

Tuesday, 25 March 2014

Internet Download Manager 6.18 Build 12 Final Retail + Crack(Updated)


Internet Download Manager (also called IDM) is a shareware download manager. It is only available for the Microsoft Windows operating system.


Instructions to install Internet Download Manager IDM 6.18 build 12(Updated)



1. Run the IDM Setup (idman618build12f.exe)

2. After installing IDM, copy and paste the Crack file of IDMan in installed folder (IDMan.exe)

3. Everytime you update IDM, fake serial notification and registration dialog will occur.     In this case, use 2 Step for activation.

4. After copy past run registry file in crack folder.

5. Note - If the Crack deleted, you may have to disable your AntiVirus Software temporarily.

This is because the Crack makes changes to the executable files of the software.The AntiVirus Software detects the Crack as a Virus.



If any problem in crack the idm please read the file named READ ME!! in crack folder for crack the idm..


Download from Here......


Friday, 14 March 2014

Remove WAT

Remove WAT



RemoveWAT can crack windows 7 sp1, windows 7 ultimate, enterprise, professional, home, Basic, etc. It’s 100% work and tested. RemoveWAT (Windows Activation Technologies) completely from the OS, whilst still retaining OS genuine status and receiving all updates. So that users can validate the illegal pirated copies of Windows 7 as genuine status forever and permanently. Also allows you to download windows update.
Features list:
  • Requires no additional processes running after patching.
  • Has a theoretical 100% success rate due to it being hardware independent.
  • Efficiently coded with safety checks to prevent damage to a Windows installation.
  • Un-install option.
  • Complete removal of all genuine related elements visible to the user, whilst keeping the core activation system active, allowing you to pass various genuine checks without issue.
  • Progress bar to allow overview of completion time.
  • A completley safe solution with zero risk of bricking your bootsector or rendering your pc unbootable
What’s new in RemoveWAT 2.2.6:
  • Now provides total WAT protection and fully disables the timebomb in evaluation copies
  • Correct Un-install
  • renames slmgr on x64 as well
  • Works on unicode systems
  • silent mode with /s switch
  • UI tweaked slightly
  • No reboot necessary
  • Passes WGA on x64
How it works:
  • Close all antivirus and firewalls, and then run the program with administrator privileges (from the internet need not be switched off)
  • Click “Remove WAT” and wait until you see the message on successful completion of the procedure
  • Computer will restart automatically
  • All the system is activated


Download From Here.....



Other Link

(if above downloaded activator not work)




Sunday, 19 January 2014

Flash Light

Flash Light For Android











Download APK file from here....
size : 360 kb






Wednesday, 8 January 2014

Windows 8.1 Download ISO

Windows 8.1 Download ISO 32 / 64 Bit Free Official

Features of Windows 8.1 Below are unique Windows 8.1 features you can check after windows 8.1 download:- 

1. Direct Desktop Boot Support  
2. Resize Apps Windows  
3. Improved Device Encryption  
4. Resistance to Everyday Malware Attacks  
5. Remote Business Data Removal in case of lost or Stolen




6. Automated Lock Down Feature  
7. Integrated VPN  
8. Broadband Tethering  
9. NFC Tap To Pair Support  
10. Web Application Proxy  
11. Enhanced Environment for Virtual Desktops

Free Download Windows 8.1 ISO


32 Bit


64 Bit




Installation Keys These are official codes for installation of Windows 8.1 These will only help for installation purpose of Windows 8.1
 
Professional-x64: MHF9N-XY6XB-WVXMC-BTDCT-MKKG7 
Professional-x86: XHQ8N-C3MCJ-RQXB6-WCHYG-C9WKB



Download Windows 8 Pro

Download Windows 8 Pro ISO 32 Bit / 64 Bit Free



Everything you think about above all is on the new Windows 8 Start screen. Tiles on the Start screen of Microsoft windows 8 are joined with individuals, applications, organizers, photographs, or online sites, and are buzzing with the most cutting edge insight, so you’re cutting-edge at a look.  Windows 8 is immaculate for PCs with just a rodent and console, those with touchscreens, and those with both. Whatever sort of PC you have, you’ll find snappy and liquid courses to switch between applications, move things around, and go easily from one place to a different one.



Microsoft Windows 8 accompanies another store for applications, the Windows Store. Open the Store right from your Start screen to skim and download windows 8 applications for cooking, photographs, brandishes, news, and a considerable measure progressively—a large number of them unlimited. The latest version is Windows 8.1 now. You can download windows 8.1 iso  Download Windows 8 and it incorporates the Xbox Music application, which gives you gain entrance to to an entire universe of music.Sign in with your Microsoft record to any of your PCs running Windows 8 and you’ll promptly see your particular underpinning, presentation inclination, and settings.

Download Windows 8 Pro ISO    

32 Bit 




 64 Bit     


Windows 8 Pro Installation Keys As per Microsoft Technet and MSDN below are two installation keys which will be required to install Windows 8 Professional. Note that these are not activation keys. These are only installation keys which you’ll need to enter during installation process.  

NG4HW-VH26C-733KW-K6F98-J8CK4 
XKY4K-2NRWR-8F6P2-448RF-CRYQH

Tuesday, 7 January 2014

Blackmart Alpha v0.99.2.44 Apk- Get Paid Android Apps for Free

Blackmart Alpha v0.99.2.44 Apk- Get Paid Android Apps for Free






Blackmart Alpha a black market where you can get any paid apps available in the market for free. It can download thousands of applications for free. It has a new market look, similar like appbrain or applanet. Also it supports all android versions and is easy to install.

Features:
  • Can download any paid apps available in android market for free.
  • Can get cracked apps.
  • Can download apps that are blocked on your device by the market.

Download From Here