Monday 27 June 2016

Android Developers Blog: Improving Stability with Private C/C++ Symbol Restrictions in Android N

Android Developers Blog: Improving Stability with Private C/C++ Symbol Restrictions in Android N

Sunday 2 August 2015

MYSQL PHP API

You will need to download the api from here.

insert_records($table, $columns, $records,true);

//BULK INSERT
$columns = array("name");
$records = array("Mwenda","Marvik","Victor");
$dbutils->bulk_insert_records($table, $columns, $records,true);


//UPDATE DATA
$where_columns = array("name");
$where_records = array("Mwenda");
$columns = array("name");
$records = array("Vicky");
$dbutils->update_record($table, $columns, $records, $where_columns, $where_records,true);


//DELETE_DATA
$columns = array("name");
$records = array("Marvik");
$dbutils->delete_record($table, $columns, $records,true);


//COMPLEX METHODS

//QUERY && FETCH ASSOC
$columns = array("name");
$records = array("Vic");
$results = $dbutils->fetch_assoc($table, $columns, $records,true);
for($i = 0;$isearch($table, $columns, $records,true);
for($i = 0;$i

View in Github

Sunday 19 July 2015

Java JDBC Tutorial

This Tutorial will help you to create basic crud(Create Read Update Delete) in java using jdbc mysql driver First of all, make sure you have the jdbc.jar file and add it to your project

How to configure the libs in eclipse and add the to your project

Source code


package com.jdbc.demo;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

import javax.swing.JOptionPane;

import com.mysql.jdbc.ResultSet;

public class MainClass {

 public static void main(String[] args) {
  
  try {
   insertData();
   queryData();
   updateData();
   queryData();
   deleteData() ;
  } catch (Exception e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   System.err.print(e.toString());
  }
 }
 
 private static Connection createConnection() throws Exception{
  /**
   * SQL STATEMENTS 
   * 
   * create database test_db;
   * 
   * create table tbl_test(_id int primary key auto_increment,fname text not null,lname text not null);
   * 
   */
  Class.forName("com.mysql.jdbc.Driver");
  String DATABASE_NAME = "test_db";
  return DriverManager.getConnection("jdbc:mysql://localhost/"+DATABASE_NAME, "root", "");
 }
 
 private static void insertData() throws Exception{
  Statement statement = createConnection().createStatement();
  String SQL = "insert into `tbl_test` (`fname`,`lname`) values ('Victor','Mwenda') ";
  boolean success = statement.execute(SQL);
  
  String executionResults = "";
  if(!success){
   executionResults = "Data inserted";
  }else{
   executionResults = "Data not inserted";
  }
  
  JOptionPane.showMessageDialog(null, executionResults);
 }
 private static void queryData() throws Exception{
  Statement statement = createConnection().createStatement();
  String SQL = "select * from `tbl_test`";
  java.sql.ResultSet results = statement.executeQuery(SQL);
  
  int i = 0;
  for(results.first();!results.isAfterLast();results.next()){ //Iterate through the results
   String firstname = results.getString("fname");//fname is the column name . . .this is the array index
   String lastname = results.getString("lname");//lname is the column name . . .this is the array index
   i++;
   String executionResults = i+" Firstname : "+firstname +" Lastname : "+lastname;
   JOptionPane.showMessageDialog(null, executionResults);
   
  }
  
 }
 private static void updateData() throws Exception{
  Statement statement = createConnection().createStatement();
  String SQL = "update `tbl_test` set `fname`='Mwenda',`lname`='Victor' where `fname`='Victor' and `lname`='Mwenda' ";
  boolean success = statement.execute(SQL);
  
  String executionResults = "";
  if(!success){
   executionResults = "Data updated";
  }else{
   executionResults = "Data not updated";
  }
  
  JOptionPane.showMessageDialog(null, executionResults);
 }
 private static void deleteData() throws Exception{
  Statement statement = createConnection().createStatement();
  String SQL = "delete from `tbl_test` where fname='Victor' and lname='Mwenda' ";
  boolean success = statement.execute(SQL);
  
  String executionResults = "";
  if(!success){
   executionResults = "Data deleted";
  }else{
   executionResults = "Data not deleted";
  }
  
  JOptionPane.showMessageDialog(null, executionResults);
 }
}




Download the project resources from here

Monday 29 June 2015

Java Lambda Demo

public class LamdaDemo {
   public static void main(String args[]){
      LamdaDemo lamda = new LamdaDemo();

      //type declaration
      BasicMaths add = (int a, int b) -> a + b;

      //no type declaration
      BasicMaths subtract = (a, b) -> a - b;

      //with return statement
      BasicMaths product = (int a, int b) -> { return a * b; };
      
      BasicMaths quotient = (int a, int b) -> a / b;

      System.out.println("1 + 1 = " + lamda.operate(1, 1, add));    
      System.out.println("1 - 1 = " + lamda.operate(1, 1, subtract));
      System.out.println("1 x 1 = " + lamda.operate(1, 1, product));
      System.out.println("1 / 1 = " + lamda.operate(1, 1, quotient));

       
   }   

   interface BasicMaths {
      int execute(int a, int b);
   }  

  
   private int operate(int a, int b, BasicMaths basicMaths){
      return basicMaths.execute(a, b);
   } 
}

Saturday 6 June 2015

How to capture Android Screenshots using batch programming.


Open any editor(I prefer Notepad) and create a .bat file

Add this source code

********************************************************
@echo off
echo This script will capture a screenshot of your android phone...
echo Trying to capture your screen
adb shell screencap -p /sdcard/screenshot.png
echo saving to your computer
adb pull /sdcard/screenshot.png
echo deleting residuals from your phone
adb shell rm -r /sdcard/screenshot.png
echo done
exit
***********************************************************

Save the file now.

Double click to open the file, or open via cmd

Voila!

Saturday 14 June 2014

Airtime Topup - Kenya



Description
An android app that enables all Android users in Kenya to top up their airtime from any mobile network in Kenya.



Visit the apps webpage

Download from Google PlayDeveloper Website

Email Developer

Call Developer