2013年7月2日火曜日

SQLite Database Basic Knowledge

1.What is SQLite
SQLite is a public domain RDBMS database engine, and is an Open Source Database which is embedded into Android and Mac OS X.
SQLite supports standard relational database features like SQL syntax, transactions and prepared statements. In addition, it requires only little memory at runtime (approx. 250 KByte).
SQLite supports the data types TEXT (similar to String in Java), INTEGER (similar to long in Java) and REAL (similar to double in Java). All other types must be converted into one of these fields before saving them in the database.
More information about SQLite can be found on the SQLite website:
http://www.sqlite.org.

2.Download page

3.SQLite on Windows
sqlite-shell-win32-x86-3071700.zip
sqlite-dll-win32-x86-3071700.zip
sqlite-analyzer-win32-x86-3071700.zip 

4.SQLite on Linux
/* For Debian or Ubuntu /*  
$ sudo apt-get install sqlite3 sqlite3-dev  
/* For RedHat, CentOS, or Fedora/*  
$ yum install SQLite3 sqlite3-dev 

5.SQLite on Mac OS X
It is already intalled, and is available on Mac OS X.

6. SQLite in Android
SQLite is available on every Android device.Using an SQLite database in Android does not require any database setup or administration.
You only have to define the SQL statements for creating and updating the database.
Afterwards the database is automatically managed for you by the Android platform.
If application creates a database, this database is by default saved in the directory: DATA/data/APP_NAME/databases/FILENAME.

7.Example
Create SQLite Database
sqlite3 test.db 

Create table
sqlite> create table mytable(id integer primary key, value text); 

Insert data
sqlite> insert into mytable(id, value) values(1, 'Micheal');  
sqlite> insert into mytable(id, value) values(2, 'Alice'); 

View data 
sqlite> select * from mytable;
1|Micheal
2|Alice

8.Android SQLite Architecture
8.1. Packages
The package android.database contains all general classes for working with databases. android.database.sqlite contains the SQLite specific classes.

8.2. SQLiteOpenHelper
To create and upgrade a database in your application you usually subclass SQLiteOpenHelper.
In this class you need to override the onCreate() and onUpgrade() methods.
onCreate() is called by the framework, if the database does not exists.
onUpgrade() is called, if the database version is increased in your application code. This method allows you to update the database schema.

8.3. SQLiteDatabase
SQLiteDatabase is the base class for working with a SQLite database in Android and provides methods to open, query, update and close the database.
More specifically SQLiteDatabase provides the insert(), update() and delete() methods.
In addition it provides the execSQL() method, which allows to execute an SQL statement directly.
Queries can be created via the rawQuery() and query() methods or via the SQLiteQueryBuilder class .
rawQuery() directly accepts an SQL select statement as input.
query() provides a structured interface for specifying the SQL query.
SQLiteQueryBuilder is a convenience class that helps to build SQL queries.

For details, you can refer to http://www.vogella.com/articles/AndroidSQLite/article.html

9.Using SQLite Sample
The following demonstrates how to work with an SQLite database.Add following code in Android Activity class to study SQLite's using.
    @Override  
    protected void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
          
        //open and create test.db
        SQLiteDatabase db = openOrCreateDatabase("test.db", Context.MODE_PRIVATE, null);  
        db.execSQL("DROP TABLE IF EXISTS person");  
        //insert person table
        db.execSQL("CREATE TABLE person (_id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR, age SMALLINT)");  
        Person person = new Person();  
        person.name = "john";  
        person.age = 30;  
        //insert data
        db.execSQL("INSERT INTO person VALUES (NULL, ?, ?)", new Object[]{person.name, person.age});  
          
        person.name = "david";  
        person.age = 33;  
        //save ContentValues key-value data  
        ContentValues cv = new ContentValues();  
        cv.put("name", person.name);  
        cv.put("age", person.age);  
        //insert ContentValues data
        db.insert("person", null, cv);  
          
        cv = new ContentValues();  
        cv.put("age", 35);  
        //update data 
        db.update("person", cv, "name = ?", new String[]{"john"});  
          
        Cursor c = db.rawQuery("SELECT * FROM person WHERE age >= ?", new String[]{"33"});  
        while (c.moveToNext()) {  
            int _id = c.getInt(c.getColumnIndex("_id"));  
            String name = c.getString(c.getColumnIndex("name"));  
            int age = c.getInt(c.getColumnIndex("age"));  
            Log.i("db", "_id=>" + _id + ", name=>" + name + ", age=>" + age);  
        }  
        c.close();  
          
        //delete data 
        db.delete("person", "age < ?", new String[]{"35"});  
          
        //close db 
        db.close();  
          
        //delete test.db
//      deleteDatabase("test.db");  
    }  
   
After running the app, we can see "test.db" file in /data/data/[PACKAGE_NAME]/databases folder.

Other Link:

Some Tools for pre-seeded databases:
-MesaSQLite
-SQLiteManager
-SQLite Database Browser

2013年6月30日日曜日

How to change the language of jDeveloper UI

Q: 1.How can you start your jDeveloper in a different language other than the OS language setting?If you want to change the display of your jdeveloper to a different language (i.e Japanese, French, English).

A: You can try the following:
Modified the jdev.conf file in jdev/bin folder to add the following JVM parameter.
In japanese case
AddVMOption -Duser.language=ja
AddVMOption -Duser.country=JP

In french case
AddVMOption -Duser.language=fr
AddVMOption -Duser.country=FR

In english case
AddVMOption -Duser.language=en
AddVMOption -Duser.country=US

For example, In japanese case,













Then,when you start the jDeveloper again, you can get japanese language UI like following.

2013年6月25日火曜日

Overview of ADF Mobile


ADF Mobile provides a way of quickly developing on-device applications for Android and iOS. Following is some knowledge about overview of the ADF Mobile technology. 
Three Types of mobile application
Native apps are built for a specific platform with the platform SDK, tools and languages, typically provided by the platform vendor (e.g. xCode/Objective-C for iOS, Eclipse/Java for Android, Visual Studio/C# for Windows Phone).
Mobile Web apps are server-side apps, built with any server-side technology (PHP, Node.js, ASP.NET) that render HTML that has been styled so that it renders well on a device form factor.
Hybrid apps, like native apps, run on the device, and are written with web technologies (HTML5, CSS and JavaScript). Hybrid apps run inside a native container, and leverage the device’s browser engine (but not the browser) to render the HTML and process the JavaScript locally.
What is Oracle ADF Mobile
Oracle ADF Mobile is a hybird framwork for mobile development. Enables development of a single source and generation of native applications for both iOS and Android devices. Coding of logic is done with the Java language. UI layer can be developed with a set of components (AMX) that generate an HTML5 based user interface. In addition Oracle ADF Mobile can incorporate local HTML5 pages and remote HTML content generated from other servers.
So, you need noticed following point.
   Java - Application logic is developed with the Java language.
   Hybrid UI Approach - For the UI developers can mix and match three approaches:Use the declarative HTML5 components provided with the framework, which provides all the normal input and layout controls you expect and also add charts/maps/gauges along with it to provide a very comprehensive UI controls.
Use other HTML5 framework like JQuery
Include content generated on remote servers – for example JSF content
   Device Feture Access - Oracle ADF simplifies access to device services such as Camera, SMS, locations, contacts and more with a simple drag and drop creation of interaction.
   Secure – ADF Mobile provides integrated security that works with your server back-end as well. Whether you’re using remote URLs, local HTML or AMX, you can secure any/all of your features with a single consistent login page. Since we also give you SQLite encryption, we are assured that your data is safe.
   Productive - Focused on a visual and declarative development approach, Oracle ADF Mobile extends the development experience provided by Oracle ADF from Web to Mobile devices. 
ADF Mobile Architecture











What is PhoneGap does here is?
About Hybird application(Web-based native apps), which has three common framwork:Titanium, PhoneGap, ADF Mobile.ADF Mobile is based party of PhoneGap, and allow you to create a "native" application using only HTML5 and JavaScript,and is a new component-driven framework:ADF Mobile AMX files.
PhoneGap will convert the web based application(developed with HTML5,CSS&JQueryMobile) into a native iOS, Android,Blackberry,Windows Phone, Plam OS and Symbian kind of an application.
Therefore, the end-user will use the app not as a web based app(meaning,not in a web browser),but as a native app.
Key benefits and features of Oracle ADF Mobile for developing hybrid mobile applications across multiple device platforms.
About Oracle ADF Mobile Demo for Developing hybrid Mobile Applications, you can refer to
http://www.youtube.com/watch?v=XWyPP55dZLU

There is a video about Overview of ADF Mobile.

2013年6月23日日曜日

How to set up your ADF Mobile development environment

ADF Mobile is licensed part of Oracle ADF, and enables development of on-device mobile applications, which runs on iOS and Android from a single source code.Mobile application development done in Oracle JDeveloper, so, at first, we need install the ADF development environment.
1.Install the ADF Development Environment
A) Before you begin, you need download and install Oracle JDeveloper. Select the Studio Developer (All Features) role when prompted.
Download website:
http://www.oracle.com/technetwork/developer-tools/jdev/downloads/index.html

For more information, see Oracle Fusion Middleware Installation Guide for Oracle JDeveloper.
Depending on the type of installer you are using, you can begin the installation process in one of the following ways:
    To launch the platform-independent installer,
    enter: java -jar jdevstudio11123install.jar.
    To launch the Windows installer, double-click the jdevstudio11123install.exe file.
    To launch the Linux installer, follow these steps:
    Ensure that the jdevstudio11123install.bin file is executable: chmod +x jdevstudio11123install.bin.
    Execute the file: ./jdevstudio11123install.bin.
If you choose to create a new Middleware Home directory, the default provided is C:\Oracle\Middleware\ for Windows, and $HOME/Oracle/Middleware/ for Linux and Unix platforms.

Notes: Ensure that you choose a directory that does not contain spaces. For example, do not use C:\Program Files as the Middleware Home.

B) Download and install the ADF Mobile extension:
    In JDeveloper, choose Help -> Check for Updates -> click Next --> Restart JDeveloper

C) Now, you need check whether or not ADF Mobile was successfully added to JDeveloper:
 #1 Select File -> New from the main menu to open the New Gallery.
 #2 Select the All Features tab.
    In the Categories pane, expand the Client Tier node and make sure it contains ADF Mobile.
    In addition, verify that you installed the correct version of ADF Mobile. To do so, select Help -> About from the main menu, then select the Extensions tab on the About Oracle JDeveloper dialog, and then examine the extension list entries by scrolling down to ADF Mobile.

Notes:You need install Oracle JDeveloper (Studio Edition) 11.1.2.3 or above.

2.Install and Configure Deployment Environment
■ iOS Simulator to be used, xcodebuild and iTunes
http://docs.oracle.com/cd/E18941_01/tutorials/setupmobileapps/jdtut_11r2_54_1.html
■ Android SDK and Platform locations
http://docs.oracle.com/cd/E18941_01/tutorials/setupmobileapps/jdtut_11r2_54_2.html

3.Define Forms Factors(Define device type resolution for Preview)
You can refer to 3.3.1 How to Configure the Development Environment for Platforms and Form Factors

Other useful link:
http://docs.oracle.com/cd/E35521_01/doc.111230/e24475/setup.htm#CEGIHAHA
Installing ADF Mobile Extension --> http://www.youtube.com/watch?v=OfrgG3Ymz7Y
Configuring your ADF Mobile development environment for Android-->http://www.youtube.com/watch?feature=player_detailpage&v=UbxyjmLxIII
ADF Mobile Debugging on iOS Devices using Xcode.mp4 -->
http://www.youtube.com/watch?v=uuQTBSMkmhU

2013年6月21日金曜日

Oracle ADF Mobile World! Hello!

ADF Mobile is Java and HTML5 framework for cross device mobile application development,and is a framework the enables the development of hybrid applications for mobile devices. Oracle ADF Mobile uses Java and HTML5 and enables developers to develop a single application that installs and runs on both iOS and Android systems.

Here are some useful links.

Home page of ADF Mobile:
http://www.oracle.com/technetwork/developer-tools/adf/overview/adf-mobile-096323.html

How to setup your JDeveloper:
http://docs.oracle.com/cd/E18941_01/tutorials/MobileTutorial/jdtut_11r2_54_1.html

Developer's Guide
http://docs.oracle.com/cd/E35521_01/doc.111230/e24475/toc.htm

Some sales stuff
http://www.oracle.com/technetwork/developer-tools/jdev/adf-mobile-development-129800.pdf

Mobile Tutorial

Oracle ADF Insider Essentials channel
Integrating the Camera - http://youtu.be/o6fBW5ZIBgI
Integrating Email- http://youtu.be/D16DGMAn8xg
Integrating the GPS - http://youtu.be/C-yHYvH7wYs
Working with Contacts - http://youtu.be/kpkJDeRH2ys

ADF Mobile SQLite integration

Notes:
If you're using the Javascript APIs to access the device services, please be aware of the following changes with regards which libraries to import in ADF Mobile v1.1 (JDev 11.1.2.4.0):
https://blogs.oracle.com/onesizedoesntfitall/entry/migrating_adf_mobile_apps_from