Category

- Technology

           - Programming on iOS

           - Programming on Android

- Japan

- My Hobby

Delicious restaurants and shops of Iwakuni City

日本語

 

I will introduce delicious restaurants and shops of Iwakuni City, Yamaguchi Prefecture, Japan.

1. Irori Sanzoku

At first, I will introduce "Irori Sanzoku Kuga" in Kuga town, Iwakuni City.

It is a classical Japanese restaurant and it is familiar to Yamaguchi and Hiroshima people.

This picture's foods are "Sanzoku-Yaki", "Sanzoku-Musubi" and "Yamame-Shio-Yaki(Grilled cheery-salmon with salt)", famous menu of this restaurant.

"Sanzoku-Yaki" is grilled chicken over charcoal fire with sweet soy-sauce.

"Sanzoku-Musubi" is big rice ball and it includes salmon, umeboshi(pickled plum), and konbu(seaweed).

All foods of this restaurant are wild and delicious.

2. Mukyuka

Mukyuka is a grilled meat restaurant in Iwakuni City and it serves delicous meats.

Especially, chuck and sparerib are very delicious.

3. ISoharu

Isoharu is a Japanese restaurant in Iwakuni City.

My recommendation is tea buckwheat noodles and sushi set.

 

Isoharu serves light and very delicious tea buckwheat noodles.
I like that Isoharu serves quail eggs with buckwheat noodle's soup.

 

Ishoharu's sushi is fresh and very delicious.

4. Italizan Izakaya fukuoka

Italian Izakaya Fukuoka is an Italian restaurant in Iwakuni City.

These are appetizer, pasta and pizza of lunch set.

Italian Izakaya Fukuoka serves elaborate dish including carpaccio of flounder and nanbanzuke(sweet and sour marinated dish) of sweetfish for appetizer.

This restaurant serves classic pasta and pizza, and these are really good.

I very soon finished these off.

5. Sobatamaya

Sobatamaya is an Okonomiyaki restaurant in Iwakuni City.

There are many Hiroshima styled Okonomiyaki restaurants in Iwakuni City that is neat to Hiroshima.

Sobatamaya's Okonomiyaki is big and delicious.

6. Suehiro

Suehiro is a Ramen restaurant in Iwakuni City.

It is good to eat Rahmen with many green onions and soybean sprouts.

7. marifu Coffee

Marifu Coffee is a cafe near Marifu Elementary School in Iwakuni City.

Marifu Blend has rich taste and delicious.

This picture is morning specials.

8. Loire

Loire is a sweets shop in Iwakuni City. 

My recommendation is "Conque".

"Conque" is made of pie dough and sweet red-been and it is very delicious.

9. matsuura-suisan

Matsuura-Suisan is a fish market near Edion in Iwakuni City.

Matsuura-Suisan serves good quality affordable puffer fish because Iwakuni City is close to Shimonoseki City, a famous place of puffer fish.

Kintai Bridge and Iwakuni Castle

We had a nice rest in Iwakuni City, Yamaguchi Prefecture, Japan. 

A symbol of Iwakuni City is Kintaikyo-Bridge.

 

Kintaikyo-Bridge is a historical arch brdige and spans the Nishiki River near Iwakuni Castle.

It was built in 1673. It was broken by floodwaters three times and it was rebuild by original method each time.

 

It was fine today and the view from Kintaikyo-Bridge were very well.

Nishiki River's water is very clean.

 

There are many Cherry Blossoms around Kintaikyo-Bridge and they are full in bloom between Late March and the beginning of April.

 

 

I went to Iwakuni Castle after Kintaikyo-Bridge.

Iwakuni Castle is on the top of Yokoyama Mountain and it is also called "Yokoyama-Castle".

Iwakuni Castle was built in 1608, but it was dismantled as per the Ikkoku-Ichijyo(One Castle Per Province) order established by the Tokugawa Shogunate in 1615.

Iwakuni Castle Castle Tower was rebuild in 1962.

 

There is the rope way for visitors to the top of Yokoyama Mountain.

 

It is 5 minutes from the rope way station to Iwakuni Castle.

There is the dry moat around Iwakuni Castle.

 

It is Iwakuni Castle Castle Tower.

The inner part of Castle Tower is museum and old swords are displayed.

 

The view of Iwakuni City from the top of Castle Tower is beautiful.

It teaches me that Iwakuni City was made along Nishiki River.

 

The foot of Yokoyama Mountain was the residence of Iwakuni Domain in the edo period and it is Kikkou Park now.

 

 

The admission ticket of Kintaikyo-Bridge, the rope way and Iwakuni Castle is sold at the entrance of Kintaikyo-Bridge.

It is 940 yen(about 8 US $).

 

 

I recommend "Itsutsubashi-no-sato", a hot spring in Iwakuni Kokusai Kanko Hotel near Kintaikyo-Bridge.

Both hotel's guests and day-trippers can get into this hot spring.

 

You can see Kintaikyo-Bridge at the viewing place of this hot spring.

Asakusa

日本語

 

I went to Asakusa, Tokyo, Japan today.

I like Asakusa because Asakusa has preserved its distinctive character. 

 

This is Senso-ji temple, the most famous place of Asakusa.

This gate's name is "Kaminari-Mon"(Thunder Gate).

The statue of Fujin,a Shinto god of wind is located on the east side on the gate and the statue of Raijin,a Shinto god of thunder is located on the west side on the gate. And "FujinRaijin-Mon" is the formal name of Kaminari-Mon.

 

The Nakamise-dori is a shopping street between Kaminarimon and Hozomon.

There are 54 shops on the east side of the Nakamise-dori and 35 shops on the west side of the Nakamise-dori.

 

Hozomon(Treasure House Gate) is appeared beyond Nakamise-dori.

 

This is five story pagoda of Senso-ji temple. It's fine building.

 

I ate eel at Unagi-Yakko.

Unagi-Yakko is a long-established restaurant in Asakusa.

Unadon(a bowl of eel and rice) of Unagi-Yakko is very delicious.

 

A jinrikisha runs against Tokyo Skytree.

 

Funawa is a Japanese sweet shop in Asakusa.

Funawa's 1F is a shop that sell Japanese sweets,such as sweet-potato paste and mitsumame topped with bean jam, and Funawa's 2F and 3F is Japanese cafe.

I ate ishobe-mochi(seaside mochi) and abekawa-mochi(roasted-soybean-powdered mochi) today. These are very delicious.

 

I feel elegance within the sound of wind chimes.

IYOTETSU SHOP AKIHABARA

 

I went to "IYOTETSU SHOP AKIHABARA" in Akihabara, Tokyo today.

"IYOTETSU SHOP" is the souvenir shop of Matsuyama City, Ehime Prefecture, Japan, and "IYOTETSU SHOP AKIHABARA" is the first store in Tokyo.

It has juice and jelly of mandarine orange which is a famous product of Ehime, and goods of "Mican" and "Dark Mican" which are the face of Ehime.

 

This shop is open only on Fridays and Saturdays and Sundays.

I hear that sales person is coming to Tokyo from Ehime only on weekends.

I bought these foods and goods.

Four kinds of mandarine orange is used for the jelly.

Misaki Port

[日本語]

 

I had the day off today and I went to Misaki Port in Miura City, Kanagawa Prefecture, Japan, to eat tuna.

 

This is Keikyu train's "Misaki Tuna Tickets" .

This tickets is very good ticket because it includes round trip train and bus fee, tuna dish tickets, leisure facility ticket, and it is only 3500 yen.

 

I went to Misaki-Guchi Station from Shinagawa Station by Keikyu train.

 

I went to Misaki Port from Misaki-Guchi Station by Keikyu bus.

There are many tuna restaurants in Misaki Port.

 

I visited Senmiraku, a restaurant managed by a tuna wholesale marchant.

 

This is "Senmiraku-don".

It includes various type of tuna meats, Akami, Chu-Toro, Negi-Toro, Nakaochi, Bin-Toro and it is very delicious.

 

It is "Nijiirosakana-go", a pleasure boat that can see fish underwater.

There are Girella punctata and Sacura margaritacea in Misaki Port.

 

Next, I crossed the Jogashima Island by a small ferry "Sanshiro".

It arrived in about 10 minutes.

 

 

This is Jyogashima Lighthouse, a famous place of Jyogashima Island.

It's the view from Jyogashima Lighthouse.

 

This is Jyogashima Keikyu Hotel.

It has a one-day hot spring "Kirara-no-Yu" and its fee is 1000 yen.(Towel rental is separately 300 yen)

It's the view in front of Jyogashima Keikyu Hotel.

We can see this view from an open-air bath of "Kirara-no-Yu".

Matsuyama City, Japan

[日本語]

 

I introduce Matsuyama City, Ehime Prefecture, Japan.

It is a temperate region and it has a lot of sightseeing spots.

Nagaoka Fireworks Festival

[日本語]

 

I went to Nagaoka Fireworks Festival in Nagaoka City, Nigata Prefecture, Japan.

Nagaoka Fireworks Festival started from August,1946 for purpose of remembrance of the dead of World War II.

It holds near Ote big bridge along Shinano River every August 2and 3, and it has many big fireworks.

This fireworks' name is "Phoenix" and it was started for praying recovery from Nigata Chuetsu Earthquake.

Its background music is "Jupiter" sung by Ayaka Hirahara.

This fireworks' name is "Kome Hyappyo Fireworks and measure ball 100 firing".

It is famous fireworks of Nagaoka Fireworks Festival, too.

Its background music is "Try looking up the sky" sung by Chikako Sawada.

It is the venue of Nagaoka Fireworks Festival near Ote big bridge along Shinano River.

We can buy tickets for reserved seat on the day of the fireworks festival.

I ate boiled ayu with salt.

It was fat and delicious.

 

I stayed Aore Nagaoka until beginning of Nagaoka Fireworks Festival.

Aore Nagaoka is Nagaoka City Hall and event venue near Nagaoka Station and it was designed by Mr.Kengo Kuma,an architect of Japan.

私が訪れた8月2日は長岡まつりのイベントが開かれていました。

I ate "Gohei-mochi",a famous food of Nigata Prefecture, at stall.

It is a big mochi(rice cake) with miso and it is delicious.

0 コメント

[Android]Sending View to Back or Front

[日本語]

 

I will introduce how to change stacking order of view as below picture.

 

Environment : Android Studio 2.2.1, API 19

 

In the case of Android, remove view from layout and set view to layout again.

Then index is set 0 and view move to back. Index is not set and view move to front.

 

Example

package net.studioks.sample1;

 

import android.app.Activity;

import android.graphics.Color;

import android.graphics.drawable.GradientDrawable;

import android.os.Bundle;

import android.view.Gravity;

import android.view.View;

import android.widget.Button;

import android.widget.RelativeLayout;

import android.widget.TextView;

import static android.support.v7.widget.ListPopupWindow.WRAP_CONTENT;

 

public class sample1 extends Activity implements View.OnClickListener {

  private TextView textView1;

  private TextView textView2;

  private Button button1;

  private Button button2;

  RelativeLayout relativeLayout;

 

  @Override

  public void onCreate(Bundle bundle){

    super.onCreate(bundle);

    relativeLayout = new RelativeLayout(this);

    setContentView(relativeLayout);

 

    textView1 = new TextView(this);

    textView1.setText("Text1");

    GradientDrawable gradient_textView1 = new GradientDrawable();

    gradient_textView1.setColor(Color.BLUE);

    textView1.setBackground(gradient_textView1);

    RelativeLayout.LayoutParams param_textView1 = new RelativeLayout.LayoutParams(300, 300);

    param_textView1.leftMargin = 0;

    param_textView1.topMargin = 0;

    param_textView1.addRule(RelativeLayout.ALIGN_TOP);

    relativeLayout.addView(textView1,param_textView1);

 

    textView2 = new TextView(this);

    textView2.setText("Text2");

    GradientDrawable gradient_textView2 = new GradientDrawable();

    gradient_textView2.setColor(Color.YELLOW);

    textView2.setBackground(gradient_textView2);

    RelativeLayout.LayoutParams param_textView2 = new RelativeLayout.LayoutParams(300, 300);

    param_textView2.leftMargin = 50;

    param_textView2.topMargin = 50;

    param_textView2.addRule(RelativeLayout.ALIGN_TOP);

    relativeLayout.addView(textView2,param_textView2);

 

    button1 = new Button(this);

    button1.setId(1);

    button1.setText("Send Label1 to Back");

    button1.setGravity(Gravity.CENTER);

    button1.setPadding(0,0,0,0);

    button1.setTextColor(Color.WHITE);

    button1.setOnClickListener(this);

    GradientDrawable gradient_button1 = new GradientDrawable();

    gradient_button1.setColor(Color.BLUE);

    button1.setBackground(gradient_button1);

    RelativeLayout.LayoutParams param_button1 = new RelativeLayout.LayoutParams(200, 50);

    param_button1.leftMargin = 0;

    param_button1.topMargin = 400;

    param_button1.addRule(RelativeLayout.ALIGN_TOP);

    relativeLayout.addView(button1,param_button1);

 

    button2 = new Button(this);

    button2.setId(2);

    button2.setGravity(Gravity.CENTER);

    button2.setPadding(0,0,0,0);

    button2.setText("Send Label1 to Front");

    button2.setTextColor(Color.WHITE);

    button2.setOnClickListener(this);

    GradientDrawable gradient_button2 = new GradientDrawable();

    gradient_button2.setColor(Color.RED);

    button2.setBackground(gradient_button2);

    RelativeLayout.LayoutParams param_button2 = new RelativeLayout.LayoutParams(200, 50);

    param_button2.leftMargin = 210;

    param_button2.topMargin = 400;

    param_button2.addRule(RelativeLayout.ALIGN_TOP);

    relativeLayout.addView(button2,param_button2);

  }

 

  public void onClick(View v) {

    switch (v.getId()){

      case 1:

        //To Back

        relativeLayout.removeView(textView1);

        relativeLayout.addView(textView1,0);

        break;

      case 2:

        //To Front

        relativeLayout.removeView(textView1);

        relativeLayout.addView(textView1);

        break;

    }

  }

}

[iOS]Sending UIView to Back or Front

[日本語]

 

I will introduce how to change stacking order of UIView as below picture.

 

Environment : Xcode 8.3, Swift 3

 

In the case of iOS, use sendSubView(toBack:) for sending UIView to back and use bringSubView(toFront:) for sending UIView to front.

 

Example

import UIKit

 

class ViewController: UIViewController {

  let label1:UILabel = UILabel();

  let label2:UILabel = UILabel();

  let button1:UIButton = UIButton();

  let button2:UIButton = UIButton();

 

  override func viewDidLoad() {

    super.viewDidLoad()

    // Do any additional setup after loading the view, typically from a nib.

    label1.frame = CGRect(x: 0, y: 0, width: 300, height: 300)

    label1.text = "Label1"

    label1.backgroundColor = UIColor.blue self.view.addSubview(label1)

 

    label2.frame = CGRect(x: 50, y: 50, width: 300, height: 300)

    label2.text = "Label2"

    label2.backgroundColor = UIColor.yellow

    self.view.addSubview(label2)

 

    button1.frame = CGRect(x: 0, y: 400, width: 200, height: 50)

    button1.backgroundColor = UIColor.blue

    button1.setTitle("Send Label1 to Back", for: .normal)

    button1.addTarget(self, action: #selector(self.touchUpButton1), for: .touchUpInside)

    self.view.addSubview(button1)

 

    button2.frame = CGRect(x: 210, y: 400, width: 200, height: 50)

    button2.backgroundColor = UIColor.red

    button2.setTitle("Send Label1 to Front", for: .normal)

    button2.addTarget(self, action: #selector(self.touchUpButton2), for: .touchUpInside) self.view.addSubview(button2)

  }

 

  override func didReceiveMemoryWarning() {

    super.didReceiveMemoryWarning()

    // Dispose of any resources that can be recreated.

  }

 

  func touchUpButton1(){

   //To Back

   self.view.sendSubview(toBack: label1)

  }

 

  func touchUpButton2(){

   //To Front self.view.bringSubview(toFront: label1)

  }

}

The famous tourists places in Kochi Prefecture

[日本語]

 

I will introduce the famous tourists famous places in Kochi Prefecture this time.

There are a lot of nice places, for example, Katsurahama Beach. 

1.Katsurahama beach

Katsurahama Beach is a national scenic area.

In summer the sunshine is strong at Katsurahama Beach.If we forget to put on sunscreen and bask in the sun for a long time, there's a possibility that get sunburn.

 

The scenery of Katurahama Beach is expansive.

 

This pic is a statue of Ryoma Sakamoto.

 

There are a lot of ice-cream stalls in Kochi in summer.

This is a sherbet ice.

 

Katsurahama Aquarium is near Katsurama Beach.

It's a small aquarium but we can enjoy very much because the show of dolphins and sea lions are held and there are corners that we can touch fishes and see stars.

This pic is Japanese lates, a big fish living in Shimanto-gawa River.

2.Muroto-misaki Cape, Muruto Dolphin center

This is Muroto-misaki Cape, a nice scenic area as equal to Katsurahama Beach.

There is an observation tower near Muroto-misaki Cape, and we can see a full view of Muroto-misaki Cape.

 

And there is Muroto Dolphin Center near Muruto-misaki Cape.

Cute dolphins receive persons with a smile.

We can touch dolphins in there.

Dolphins performed several acrobatics.

3.Monet's garden

There is "Kitagawa Villeage Monet's Garden Marmottan" in Kitagawa Villeage, Aki Country, Kochi Prefecture.

 

Claude Monet, a founder of French Impressionist paintings, is known for making "Water Garden" with many water lilies and "Flower Garden" with many colorful flowers in his house at Giverny, France. Kitagawa Villeage made Monet's Garden in collaboration with Geverny.

 

This is "Water Garden" with many water lilies.

This scenery is reminiscent of Monet's masterpiece,"Water Lilies".

This is "Flower Garden".

It is most beautiful during Spring.

 

This building is Gallery & Shop.

It has some reproduction paintings of Monet and souvenirs.

 

There is a cafe and we can take a rest after waling around gardens.

I ate a chiffon cake and drank orange juice this time.

4.Anpanman MUSEUM

There is Anpanman Museum in Kami City, Kochi Prefecture.
(Kami City is the birthplace of Takashi Yanase, a writer of Anpanman.

There are many pictures and statues of Anpanman's characters in it.

Especially, big pictures of Anpanman, Shokupanman, Currypanman and Bikinman are very wonderful.

It is a suitable place for the family with the children.

5.Kaida-ya

There is Kaida-Ya, a eel restaurant along Prefecture Root 14 that go to Katsurahama Beach from Kochi Airport and it is in Nangoku City in Kochi Prefecture.

 

It's signal flag is a signboard of cessna plane.

A lot of people visit it and we must wait for two hours at lunchtime.

 

This pic is "Unajyu"(a broiled eel served over rice in a lacquered box).

Some eel cook broil eel carefully and heartily.An eel's skin is crisp.

 

This pic is Ms.Michelle Sung Wie, an American professional golf player.

She visited this restaurant before.

This restaurant is one of famous restaurants in Kochi.

The famous tourists places in Kochi City

[日本語]

 

I did sightseeing in Kochi City, the capital of Kochi Prefecture after Ekin Festival.

I will introduce the famous tourists places in Kochi City. 

1.Kochi Castle

This is Kochi Castle, a symbol of Kochi City.

Kochi Castle's Castle Tower was build in Early-Edo period and it retains its original structure.

This castle's white wall is beautiful.

This pic is the scenery from Kochi Castle's Castle Tower.

2.Sunday Market

Sunday Market is held along Ottesuji, a street near Kochi Castle every sunday.

Fresh vegetables and craft objects are sold at this market.

3.Hirome Ichiba

There is "Hirome Ichiba(Market)" near Kochi Castle.

It has many restaurants serving Kochi's foods.

There are already a lot of people at 11 o'clock.

I recommend "bonito tataki",a famous food of Kochi.

My most favorite restaurant is "Myojinmaru".

It is known as performance of baking bonito with straws.

This is Myojinmaru's bonito tataki.

The front is set of bonito tataki sauce and salt.

The back is bonito tataki sushi.

They are very delicious.

4.Tramcar(TosaDEN)

Tramcar(it is operated by Tosaden Traffic Co.,Ltd.) is useful for sightseeing around Kochi City.

A flat fare of 200 yen is charged on tramcar in Kochi City.

There are various color types of tramcars.

Ekin Festival

[日本語]

 

"Ekin Festival" is held in Akaoka,Konan City,Kochi Prefecture,Japan every Saturday and Sunday in 3rd Week of July.

"Ekin" is Kinzo Hirose's nickname and he is a painter of late-Edo period and early-Meiji period.

 

Ekin was born in Tosa domain(Kochi Prefecture) in 1812 and he became chief retainer of Tosa domain in his young age.

But he was suspected to copy a famous Kano school's work and he was discharged from Tosa domain.

After that he lived in Akaoka and became a town painter.

He painted a lot of Shibaie-byobu(Kabuki story based picture) at town's people request.

Ekin Festival was started from 1977.

Ekin's masterpieces are awakened once a year during July, when they appear at the annual Suruta-Hachimangu Shrine Grand Festival.

 

Ekin's masterpieces are decollated in Akaoka at 19:00.

The sun descend at 20:00 and Ekin's masterpieces are very fantastic.

The owner explains the Ekin's picture.

There are a lot of street stall along the street of the town.

Lanterns heap up the festival.

I found "Toyonoume",a local sake(an alcoholic beverage of Japanese origin that is made from fermented rice) of Akaoka at Ekin Festival.

It is called "Ginjyo-Shu of Tosa's summer" and it tastes dry and light.I think it is perfect for summer.

It is perfect fit for seared bonito slice,a famous fish based-cooking of Kochi Prefecture.

 

Nisikawaya is a long established Japanese confectioner in Akaoka.

This shop was established in 1688.

It is at street where Ekin Festival is held and it has some arts of Edo-Period and we can see them.

This pic is Japanese-style confectionery and green tea and it is 500 yen.

This confectionery is include chestnuts and it's name is "Kanoka".

 

This is "Ekin-Gura", a building in which to store Ekin's masterpieces.

 

Bentenza,a theater,is behind Ekin-Gura.

People in Akaoka Town play Kabuki which become model for Ekin's masterpieces in Bentenza at Ekin Festival.

Bentenza also holds some another events of Kabuki, Kyogen and Rakugo.

 

Berry dance and bingo game are held at a live place.

It is full of excitement.

[Android]Color gradation and rounding corners

[日本語]

 

I will introduce how to set gradation on a background color of View and round corners of View and on Android.

 

Environment:Android Studio 2.2.1, API 19

  

Use GradientDrawable for setting color gradation and rounding corners.

Set gradient colors to GradientDrawable's argument and declare gradation direction using Orientation.

GradientDrawable gradient = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[]{Color.BLUE, Color.WHITE});

Use setCornerRadius for rounding corners of View.

gradient.setCornerRadius(5);

Use setCornerRadius for rounding corners of View.

private Button buttonSample = new Button(this);

buttonSample.setBackground(gradient);

 

[Sample Code]

package net.studioks.sample1;

 

import android.app.Activity;

import android.graphics.Color;

import android.graphics.drawable.GradientDrawable;

import android.os.Bundle;

import android.widget.Button;

import android.widget.RelativeLayout;

 

public class sample1 extends Activity {

  private Button buttonSample;

 

  @Override

  public void onCreate(Bundle bundle){

    super.onCreate(bundle);

    RelativeLayout relativeLayout = new RelativeLayout(this);

    setContentView(relativeLayout);

    buttonSample = new Button(this);

    buttonSample.setText("Sample");

    buttonSample.setTextColor(Color.WHITE);

    buttonSample.setPadding(0,0,0,0);

    GradientDrawable gradient = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[]{Color.BLUE, Color.WHITE});

    gradient.setCornerRadius(5);

    buttonSample.setBackground(gradient);

    RelativeLayout.LayoutParams param = new RelativeLayout.LayoutParams(100, 50);

    param.leftMargin = 20;

    param.topMargin = 10;

    param.addRule(RelativeLayout.ALIGN_TOP);

    relativeLayout.addView(buttonSample,param);

  }

}

0 コメント

[iOS]Color gradation and rounding corners

[日本語]

 

I will introduce how to set gradation on a background color of View and round corners of View on iOS.

 

Environment:Xcode 8, Swift 3

 

Use CAGradientLayer to set color gradation to UIView on iOS.

Set gradient colors to CAGradientLayer's colors method and set gradation direction using startPoint and endPoint of CAGradientLayer.

At last, set CAGradientLayer to UIView's layer using insertSublayer.

let buttonSample:UIButton = UIButton()

let gradientLayer = CAGradientLayer()

gradientLayer.frame = buttonSample.bounds

let color1:CGColor = UIColor.blue.cgColor

let color2:CGColor = UIColor.white.cgColor

gradientLayer.colors = [color1, color2]

gradientLayer.startPoint = CGPoint(x: 0, y: 0)

gradientLayer.endPoint = CGPoint(x: 1, y: 1)

buttonSample.layer.insertSublayer(gradientLayer, at: 0)

 

Use cornerRadius of UIView's CALayer for rounding corners of UIView.

buttonSample.layer.cornerRadius = 5

 

[Sample Code]

import UIKit

 

class ViewController: UIViewController {

  let buttonSample:UIButton = UIButton();

 

  override func viewDidLoad() {

    super.viewDidLoad()

    // Do any additional setup after loading the view, typically from a nib.

    buttonSample.frame = CGRect(x: 10, y: 10, width: 100, height: 50)

    buttonSample.setTitle("Sample", for: .normal)

    let gradientLayer = CAGradientLayer()

    gradientLayer.frame = buttonSample.bounds

    let color1:CGColor = UIColor.blue.cgColor

    let color2:CGColor = UIColor.white.cgColor

    gradientLayer.colors = [color1, color2]

    gradientLayer.startPoint = CGPoint(x: 0, y: 0)

    gradientLayer.endPoint = CGPoint(x: 1, y: 1)

    buttonSample.layer.insertSublayer(gradientLayer, at: 0)

    buttonSample.layer.cornerRadius = 5

    self.view.addSubview(buttonSample)

  }

 

  override func didReceiveMemoryWarning() {

    super.didReceiveMemoryWarning()

    // Dispose of any resources that can be recreated.

  }

}

Delicious Restaurants and Cafe in Kamakura

[日本]

 

I will introduce delicious restaurants and cafe I found in Kamakura.

 

1.Kyoraian

There are some famous beef stew restaurants in Kita-Kamakura, Kanagawa Prefecture, Japan.

Kyoraian is the most famous beef stew restaurant in Kita-Kamakura.

 

Kyoraian has a fine garden.

Hydrangea is blooming.

Kyoraian opens at eleven,but there is a line in front of the entrance of Kyoraian at eleven.

I recommend to come to Kyoraian a little ahead of an opening time.

 

This is beef stew set of Kyoraian.

This beef is very soft and beef stew is very delicious.

 

Coffee that is served at the end of beef stew is delicious.

2.Kamakura Tetra

This is Kamakura Tetra, a Japanese style sweets cafe near Kencho-ji in Kita-Kamakura.

Kamakura Tetra serves classic Hon-Warabimochi.

This cafe makes Hon-Warabimochi after taking an order and it takes about 15 minutes to cook it.

But it is very delicious and I don't mind waiting.

 

I ate Hon-Warabimochi with soybean flour and I enjoyed its texture.

3.Mushinan

This is Mushinan, a Japanese style cafe near Enoshima Electric Railway Wadazuka Station.

 

Enoshima Electric Railway's train is running close by Mushinan

 

This is Anmitsu, a popular food of this cafe.

It is very sweet and delicious.

I recommend to go to this cafe early time, because this cafe is very popular and customers wait for two hours even if it is weekday.

Kamakura's Hydrangea

[日本語]

 

June is the season of hydrangea in Japan.

I went to Kamakura City, a famous place of hydrangea.

1.Hasedera

I went to Hasedera near Enoshima Electric Railway Hase Station in Kamakura,Japan.

Hasedera is Buddhist temple of Jodo shu and it is on the foot of Kannon mountain.

Hasedera is known as a famous place of hydrangea.

Hasedera has the circuit style garden and two ponds,Myouchiike pond and Houjyouike pond, near the entrance.

 

There is Kannon-do hall on the middle of Kannon mountain and it has Kannon Buddhisattva with Eleven Headed.

 

There is walking pass from the side of Kannon-do hall.There are 2500 hydrangeas around walking pass and it is called "Ajisai-no-komichi(hydrangea road)".

It is very crowded on July, the season of hydrangea in Japan, and we need to take a number.

 

Hydrangeas of "Ajisai-no-komichi(hydrangea road)" are very beautiful.

 

We can see Yuigahama from the top of "Ajisai-no-komichi(hydrangea road)".

2.Engaku-ji

Next, I went to Engaku-ji near JR Kita-Kamakura Station.

 

Engaku-ji has a lot of hydrangeas.

Engaku-ji is Zen Buddhist temple and it was built to mourn for dead soldiers of the Mongol invasions by Hojo Tokimune and Mugaku Sogen in 1282.

Engaku-ji has many buildings,gardens and ponds,and we can enjoy to see them.

 

- Sanmon Gate(Main Gate)

 

- Butsu-den(Buddha hall)

 

- Hojo(Abbot's quarters)

Hojo's Japanese garden

 

- Myoukouchi pond

3.MeiGETSU-IN

I went to Meigetsu-in after Engaku-ji.

Another name of Meigetsu-in is "Ajisai-dera(Hydrangea Temple)" and it has a lot of hydrangeas.

Meigetsu-in is a Rinzai Zen temple of the Kencho-ji school.

It has Japanese garden in Hojo(Abbot's quarters) like another Zen temples.

 

There is a tomb of Tokiyori Hojo, the fifth shikken(regent) of Kamakura shogunate in Meigetsu-in.

Uwajima Castle and Tenshaen

[日本語]

 

I went to Uwajima City,Ehime Prefecture,Japan.

The loard of Uwajima was Date Family in Edo Period, and there are two places made by Date Family in Uwajima City.

They are Uwajima Castle and Tenshaen.

 

This is Uwajima Castle's Castle Tower.

Uwajima Castle's Castle Tower has been remaining from Edo Period, and it is one of "The 12 Castles of Existing Castle Towers".

The first Castle Tower was made by Takatora Todo in 1602, and Munetoshi Date rebuilt it in 1666.

 

These pictures are the inside of Castle Tower.

 

It is the view from Castle Tower.

We can see a full view of Uwajima City from Castle Tower.

 

Next, I moved to Tenshaen near Uwajima Castle.

 

Munetoshi Date, the second lord of Uwajima Domain, made Hamagoten in 1672.

And Munetoshi Date rebuilt the part of Hamagoten and made big garden called "Tenshaen".

Tenshaen has beautiful ponds and gardens.

 

The origin of "Tenshaen" comes from Chinese poetry of Masamune Date.

 

Iris was in full bloom on every May.

And wisteria and bamboo of this garden are famous, too.

[Andorid]How to capture screen

[日本語]

 

I introduce how to capture screen on Android this time.

 

環境:Android Studio 2.2.1, API 19

 

You can capture screen every views on Android.

At first, use setDrawingCacheEnabled(true) and getDrawingCache, and you can get view's capture.

 

And you must use setDrawingCacheEnabled(false) after getting view's capture.

private View view1;

・・・・・・・・・・・・・・・・・

view1.setDrawingCacheEnabled(true);

Bitmap bmp = Bitmap.createBitmap(view1.getDrawingCache());

view1.setDrawingCacheEnabled(false);

 

Sample code is below.

package net.studioks.sample1;

 

import android.app.Activity;

import android.graphics.Bitmap;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.ImageView;

import android.widget.RelativeLayout;

import android.widget.TextView;

 

public class sample1 extends Activity {

  private TextView textView1;

  private ImageView imageView1;

  private Button button1;

 

  RelativeLayout relativeLayout;

 

  @Override

  public void onCreate(Bundle bundle) {

    super.onCreate(bundle);

    relativeLayout = new RelativeLayout(this);

    setContentView(relativeLayout);

 

    textView1.setText("Test");

    RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(200,100);

    params1.leftMargin = 10;

    params1.topMargin = 0;

    relativeLayout.addView(textView1,params1);

 

    imageView1.setScaleType(ImageView.ScaleType.FIT_XY);

    RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams(400,400);

    params2.leftMargin = 10;

    params2.topMargin = 110;

    relativeLayout.addView(imageView1,params2);

 

    button1.setText("Get Image");

    button1.setOnClickListener(new View.OnClickListener() {

      @Override

      public void onClick(View v) {

        textView1.setDrawingCacheEnabled(true);

        Bitmap bmp = Bitmap.createBitmap(textView1.getDrawingCache());

        textView1.setDrawingCacheEnabled(false);

        imageView1.setImageBitmap(bmp);

      }

    });

    RelativeLayout.LayoutParams params3 = new RelativeLayout.LayoutParams(400,400);

    params3.leftMargin = 10;

    params3.topMargin = 515;

    relativeLayout.addView(button1,params3);

  }

}

[iOS]How to capture screen

[日本語]

 

I introduce how to capture screen and make a bitmap image on iOS this time.

 

Environment:Xcode 8.3, Swift 3

 

Sample code is below.

import UIKit

 

class ViewController: UIViewController {

  let label1:UILabel = UILabel()

  let imageView1:UIImageView = UIImageView()

  let button1:UIButton = UIButton()

 

  override func viewDidLoad() {

    super.viewDidLoad()

    // Do any additional setup after loading the view, typically from a nib.

    label1.frame = CGRect(x: 10, y: 20, width: 100, height: 100)

    label1.text = "Label1"

    label1.backgroundColor = UIColor.blue

    self.view.addSubview(label1)

 

    imageView1.frame = CGRect(x: 10, y: 125, width: 300, height: 300)

    imageView1.layer.borderWidth = 0.5

    imageView1.contentMode = .scaleAspectFit

    self.view.addSubview(imageView1)

 

    button1.frame = CGRect(x: 10, y: 430, width: 100, height: 50)

    button1.backgroundColor = UIColor.blue

    button1.layer.cornerRadius = 5

    button1.setTitle("Button1", for: .normal)

    button1.addTarget(self, action: #selector(self.touchUpButton1), for: .touchUpInside)

    self.view.addSubview(button1)

  }

 

  override func didReceiveMemoryWarning() {

    super.didReceiveMemoryWarning()

    // Dispose of any resources that can be recreated.

  }

 

  func touchUpButton1(){

    //Get context

    let rect = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)

    UIGraphicsBeginImageContextWithOptions(rect.size, false, 0.0)

    let context: CGContext = UIGraphicsGetCurrentContext()!

 

    //Write screen's objects' info at context

    self.view.layer.render(in: context)

 

    //Get UIImage

    let capturedImage : UIImage = UIGraphicsGetImageFromCurrentImageContext()!

 

    //Close context

    UIGraphicsEndImageContext()

    imageView1.image = capturedImage

  }

}

At first, use UIGraphicsBeginImageContextWithOptions, and make context of bitmap for capturing screen.

And write screen's objects' info at context.("self.view.layer.render(in:context)")

 

And use UIGraphicsGetImageFromCurrentImageContext, and get UIImage from context.

At last, use UIGraphicsEndImageContext, and close context.

[Android]Sqlite Database Programming

[日本語]

 

You can use Sqlite for saving data on Android.

 

Environment: Android Studio 2.2.1, API 19

 

1.Preparation

Make class extended SqLiteOpenHelper and declare database layout.

private final static String DB_NAME = "sample1.db";

private final static String DB_TABLE = "SampleTable";

private final static int DB_VERSION = 1;

 

private class SampleDBHelper extends SQLiteOpenHelper {

  public SampleDBHelper(Context context) {

    super(context, DB_NAME, null, DB_VERSION);

  }

 

  @Override

  public void onCreate(SQLiteDatabase db) {

    db.execSQL("create table if not exists " + DB_TABLE + "(id text primary key,name text,type integer,image BLOB)");

  }

 

  @Override

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

    if (newVersion == 2) {

      db.execSQL("alter table " + DB_TABLE + " add column newField integer default 0");

    }

  }

}

You can define table layout to use "Create Table" in onCreate method.

You can change table layout to use "Alter Table" in onUpgrade method, when application version is up.

 

When you want to save Bitmap data, define BLOB data type.

 

2.How to Insert data

Use getWritableDatabase method of class which is made by SQLiteOpenHelper, and you can get writable SQLiteDatabase class.
When you execute InsertOrThrow method of SQLiteDatabase class, and new data is inserted in Sqlite.

And you'd better not use Insert method of SQLiteDatabase class, because this method don't return Exception class when error occur.

private ImageView imageView1;

private Button buttonInsert;

RelativeLayout relativeLayout;

Context context;

 

@Override

public void onCreate(Bundle bundle) {

  super.onCreate(bundle);

  context = getApplicationContext();

  relativeLayout = new RelativeLayout(context);

  setContentView(relativeLayout);

 

  imageView1 = new ImageView(context);

  Bitmap bmp = BitmapFactory.decodeResource(getResources(),R.drawable.edit);

  imageView1.setImageBitmap(bmp);

  imageView1.setAdjustViewBounds(true);

  RelativeLayout.LayoutParams param1 = new RelativeLayout.LayoutParams(300, 300);

  param1.leftMargin = 10;

  param1.topMargin = 10;

  param1.addRule(RelativeLayout.ALIGN_TOP);

  relativeLayout.addView(imageView1,param1);

 

  buttonInsert = new Button(context);

  buttonInsert.setText("Insert");

  buttonInsert.setOnClickListener(new View.OnClickListener() {

    @Override

    public void onClick(View v) {

      execInsert();

    }

  });

  RelativeLayout.LayoutParams param2 = new RelativeLayout.LayoutParams(300, 150);

  param2.leftMargin = 10;

  param2.topMargin = 320;

  param2.addRule(RelativeLayout.ALIGN_TOP);

  relativeLayout.addView(buttonInsert,param2);

}

 

private void execInsert(){

  try{

    SampleDBHelper dbHelper = new SampleDBHelper(context);

    SQLiteDatabase db = dbHelper.getWritableDatabase();

 

    ContentValues values = new ContentValues();

    values.put("id","0000000001");

    values.put("name","Name-1");

    values.put("type",1);

 

    Bitmap bmp = ((BitmapDrawable)imageView1.getDrawable()).getBitmap();

    if (bmp != null) {

      ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

      bmp.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);

      byte[] bytes = byteArrayOutputStream.toByteArray();

      values.put("image", bytes);

    }

    db.insertOrThrow(DB_TABLE,null,values);

  }catch(Exception e){

    Log.e("touchInsertButton",e.toString());

  }

}

Use ContentValues to set field names and values.

If you want to save Bitmap Data, you must change Bitmap to byte data type.

 

3.How to update data.

Use update method of SQLiteDatabase class, you can update data in Sqlite.

private ImageView imageView1;

private Button buttonUpdate;

RelativeLayout relativeLayout;

Context context;

 

@Override

public void onCreate(Bundle bundle) {

  super.onCreate(bundle);

  context = getApplicationContext();

 

  relativeLayout = new RelativeLayout(context);

  setContentView(relativeLayout);

 

  imageView1 = new ImageView(context);

  Bitmap bmp = BitmapFactory.decodeResource(getResources(),R.drawable.edit);

  imageView1.setImageBitmap(bmp);

  imageView1.setAdjustViewBounds(true);

  RelativeLayout.LayoutParams param1 = new RelativeLayout.LayoutParams(300, 300);

  param1.leftMargin = 10;

  param1.topMargin = 10;

  param1.addRule(RelativeLayout.ALIGN_TOP);

  relativeLayout.addView(imageView1,param1);

 

  buttonUpdate = new Button(context);

  buttonUpdate.setText("Update");

  buttonUpdate.setOnClickListener(new View.OnClickListener() {

    @Override

    public void onClick(View v) {

     execUpdate();

    }

  });

  RelativeLayout.LayoutParams param4 = new RelativeLayout.LayoutParams(300, 150);

  param4.leftMargin = 10;

  param4.topMargin = 640;

  param4.addRule(RelativeLayout.ALIGN_TOP);

  relativeLayout.addView(buttonUpdate,param4);

 }

 

private void execUpdate(){

  try{

    SampleDBHelper dbHelper = new SampleDBHelper(context);

    SQLiteDatabase db = dbHelper.getWritableDatabase();

 

    ContentValues values = new ContentValues();

    values.put("name"," Name-2");

 

    Bitmap bmp = ((BitmapDrawable)imageView1.getDrawable()).getBitmap();

    if (bmp != null) {

      ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

      bmp.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);

      byte[] bytes = byteArrayOutputStream.toByteArray();

      values.put("image", bytes);

    }

 

    String whereId = "id = ? and type = ?";

    String whereArgs[] = new String[2];

    whereArgs[0] = "0000000001";

    whereArgs[1] = "1";

 

    db.update(DB_TABLE,values,whereId,whereArgs);

  }catch(Exception e){

    Log.e("touchUpdateButton",e.toString());

  }

}

You can use ContentValues to set field names and values like inserting data.

You can set your search criteria to the third argument and the fourth argument of update method.

 

4.How to delete data

Use delete method of SQLiteDatabase class, you can delete data in Sqlite.

Method of setting your search criteria is the same as updating data.

private ImageView imageView1;

private Button buttonDelete;

RelativeLayout relativeLayout;

Context context;

 

@Override

public void onCreate(Bundle bundle) {

  super.onCreate(bundle);

  context = getApplicationContext();

 

  relativeLayout = new RelativeLayout(context);

  setContentView(relativeLayout);

 

  imageView1 = new ImageView(context);

  Bitmap bmp = BitmapFactory.decodeResource(getResources(),R.drawable.edit);

  imageView1.setImageBitmap(bmp);

  imageView1.setAdjustViewBounds(true);

  RelativeLayout.LayoutParams param1 = new RelativeLayout.LayoutParams(300, 300);

  param1.leftMargin = 10;

  param1.topMargin = 10;

  param1.addRule(RelativeLayout.ALIGN_TOP);

  relativeLayout.addView(imageView1,param1);

 

  buttonDelete = new Button(context);

  buttonDelete.setText("Delete");

  buttonDelete.setOnClickListener(new View.OnClickListener() {

    @Override

    public void onClick(View v) {

     execDelete();

    }

  });

  RelativeLayout.LayoutParams param5 = new RelativeLayout.LayoutParams(300, 150);

  param5.leftMargin = 10;

  param5.topMargin = 800;

  param5.addRule(RelativeLayout.ALIGN_TOP);

  relativeLayout.addView(buttonDelete,param5);

 }

 

private void execDelete(){

  try{

    SampleDBHelper dbHelper = new SampleDBHelper(context);

    SQLiteDatabase db = dbHelper.getWritableDatabase();

 

    String whereClause = "id = ?";

    String whereArgs[] = new String[1];

    whereArgs[0] = "0000000001";

 

    db.delete(DB_TABLE,whereClause,whereArgs);

  }catch(Exception e){

    Log.e("touchDeleteButton",e.toString());

  }

}

 

5.How to select data

When you select data in Sqlite, execute getReadableDatabase method of class which is made by SQLiteOpenHelper, and get SQLiteDatabase class(read only).

After, Use rawQuery method of SQLiteDatabase class, and you can select data in Sqlite.

private ArrayList _id = new ArrayList();

private ArrayList _name = new ArrayList();

private ArrayList _image = new ArrayList();

 

private void execSelect(){

  try{

    byte[] dataValue;

    Bitmap bmp = null;

    _id.clear();

    _name.clear();

    _image.clear();

 

    SampleDBHelper dbHelper = new SampleDBHelper(context);

    SQLiteDatabase db = dbHelper.getReadableDatabase();

 

    String sql = "select id,name,image from " + DB_TABLE + " where type=1 order by id";

 

    Cursor c = db.rawQuery(sql, null);

 

    int recordCount = c.getCount();

    if (recordCount > 0) {

      c.moveToFirst();

      for (int i = 0; i < recordCount; i++) {

        _id.add(c.getString(0)); //id

        _name.add(c.getString(1)); //name

        dataValue = c.getBlob(2); //image

        if (dataValue != null) {

          bmp = BitmapFactory.decodeByteArray(dataValue, 0, dataValue.length);

          _image.add(bmp); } c.moveToNext();

        }

      }

      c.close();

   }catch(Exception e){

     Log.e("touchSelectButton",e.toString());

   }

}

 

・Sample Code

package net.studioks.sample1;

 

import android.app.Activity;

import android.content.ContentValues;

import android.content.Context;

import android.database.Cursor;

import android.database.sqlite.SQLiteDatabase;

import android.database.sqlite.SQLiteOpenHelper;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import android.graphics.drawable.BitmapDrawable;

import android.os.Bundle;

import android.util.Log;

import android.view.View;

import android.widget.Button;

import android.widget.ImageView;

import android.widget.RelativeLayout;

import java.io.ByteArrayOutputStream;

import java.util.ArrayList;

 

public class sample1 extends Activity {

  private ImageView imageView1;

  private Button buttonInsert;

  private Button buttonSelect;

  private Button buttonUpdate;

  private Button buttonDelete;

  RelativeLayout relativeLayout;

  Context context;

 

  @Override

  public void onCreate(Bundle bundle) {

    super.onCreate(bundle);

    context = getApplicationContext();

 

    relativeLayout = new RelativeLayout(context);

    setContentView(relativeLayout);

 

    imageView1 = new ImageView(context);

    Bitmap bmp = BitmapFactory.decodeResource(getResources(),R.drawable.edit);

    imageView1.setImageBitmap(bmp);

    imageView1.setAdjustViewBounds(true);

    RelativeLayout.LayoutParams param1 = new RelativeLayout.LayoutParams(300, 300);

    param1.leftMargin = 10;

    param1.topMargin = 10;

    param1.addRule(RelativeLayout.ALIGN_TOP);

    relativeLayout.addView(imageView1,param1);

 

    buttonInsert = new Button(context);

    buttonInsert.setText("Insert");

    buttonInsert.setOnClickListener(new View.OnClickListener() {

      @Override

      public void onClick(View v) {

        execInsert();

      }

    });

    RelativeLayout.LayoutParams param2 = new RelativeLayout.LayoutParams(300, 150);

    param2.leftMargin = 10;

    param2.topMargin = 320;

    param2.addRule(RelativeLayout.ALIGN_TOP);

    relativeLayout.addView(buttonInsert,param2);

 

    buttonSelect = new Button(context);

    buttonSelect.setText("Select");

    buttonSelect.setOnClickListener(new View.OnClickListener() {

      @Override

      public void onClick(View v) {

        execSelect();

      }

    });

    RelativeLayout.LayoutParams param3 = new RelativeLayout.LayoutParams(300, 150);

    param3.leftMargin = 10;

    param3.topMargin = 480;

    param3.addRule(RelativeLayout.ALIGN_TOP);

    relativeLayout.addView(buttonSelect,param3);

 

    buttonUpdate = new Button(context);

    buttonUpdate.setText("Update");

    buttonUpdate.setOnClickListener(new View.OnClickListener() {

      @Override

      public void onClick(View v) {

        execUpdate();

      }

    });

    RelativeLayout.LayoutParams param4 = new RelativeLayout.LayoutParams(300, 150);

    param4.leftMargin = 10;

    param4.topMargin = 640;

    param4.addRule(RelativeLayout.ALIGN_TOP);

    relativeLayout.addView(buttonUpdate,param4);

 

    buttonDelete = new Button(context);

    buttonDelete.setText("Delete");

    buttonDelete.setOnClickListener(new View.OnClickListener() {

      @Override

      public void onClick(View v) {

        execDelete();

      }

    });

    RelativeLayout.LayoutParams param5 = new RelativeLayout.LayoutParams(300, 150);

    param5.leftMargin = 10;

    param5.topMargin = 800;

    param5.addRule(RelativeLayout.ALIGN_TOP);

    relativeLayout.addView(buttonDelete,param5);

  }

 

  private void execInsert(){

    try{

      SampleDBHelper dbHelper = new SampleDBHelper(context);

      SQLiteDatabase db = dbHelper.getWritableDatabase();

 

      ContentValues values = new ContentValues();

      values.put("id","0000000001"); values.put("name","Name-1");

      values.put("type",1);

 

      Bitmap bmp = ((BitmapDrawable)imageView1.getDrawable()).getBitmap();

      if (bmp != null) {

        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

        bmp.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);

        byte[] bytes = byteArrayOutputStream.toByteArray();

        values.put("image", bytes);

      }

      db.insertOrThrow(DB_TABLE,null,values);

    }catch(Exception e){

      Log.e("touchInsertButton",e.toString());

    }

  }

 

  private void execUpdate(){

    try{

      SampleDBHelper dbHelper = new SampleDBHelper(context);

      SQLiteDatabase db = dbHelper.getWritableDatabase();

 

      ContentValues values = new ContentValues();

      values.put("name"," Name-2");

 

      Bitmap bmp = ((BitmapDrawable)imageView1.getDrawable()).getBitmap();

      if (bmp != null) {

        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

        bmp.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);

        byte[] bytes = byteArrayOutputStream.toByteArray();

        values.put("image", bytes);

      }

 

      String whereId = "id = ? and type = ?";

      String whereArgs[] = new String[2];

      whereArgs[0] = "0000000001";

      whereArgs[1] = "1";

 

      db.update(DB_TABLE,values,whereId,whereArgs);

    }catch(Exception e){

      Log.e("touchUpdateButton",e.toString());

    }

  }

 

  private void execDelete(){

    try{

      SampleDBHelper dbHelper = new SampleDBHelper(context);

      SQLiteDatabase db = dbHelper.getWritableDatabase();

 

      String whereClause = "id = ?";

      String whereArgs[] = new String[1];

      whereArgs[0] = "0000000001";

 

      db.delete(DB_TABLE,whereClause,whereArgs);

    }catch(Exception e){

      Log.e("touchDeleteButton",e.toString());

    }

  }

 

  private ArrayList _id = new ArrayList();

  private ArrayList _name = new ArrayList();

  private ArrayList _image = new ArrayList();

 

  private void execSelect(){

    try{

      byte[] dataValue; Bitmap bmp = null; _id.clear();

      _name.clear();

      _image.clear();

 

      SampleDBHelper dbHelper = new SampleDBHelper(context);

      SQLiteDatabase db = dbHelper.getReadableDatabase();

 

      String sql = "select id,name,image from " + DB_TABLE + " where type=1 order by id";

 

      Cursor c = db.rawQuery(sql, null);

      int recordCount = c.getCount();

      if (recordCount > 0) {

        c.moveToFirst();

        for (int i = 0; i < recordCount; i++) {

          _id.add(c.getString(0)); //id

          _name.add(c.getString(1)); //name

          dataValue = c.getBlob(2); //image

          if (dataValue != null) {

            bmp = BitmapFactory.decodeByteArray(dataValue, 0, dataValue.length);

            _image.add(bmp);

          }

          c.moveToNext();

        }

      }

      c.close();

    }catch(Exception e){

      Log.e("touchSelectButton",e.toString());

    }

  }

 

  private final static String DB_NAME = "sample1.db";

  private final static String DB_TABLE = "SampleTable";

  private final static int DB_VERSION = 1;

 

  private class SampleDBHelper extends SQLiteOpenHelper {

    public SampleDBHelper(Context context) {

      super(context, DB_NAME, null, DB_VERSION);

    }

 

    @Override

    public void onCreate(SQLiteDatabase db) {

      db.execSQL("create table if not exists " + DB_TABLE + "(id text primary key,name text,type integer,image BLOB)");

    }

 

    @Override

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

      if (newVersion == 2) {

        db.execSQL("alter table " + DB_TABLE + " add column newField integer default 0");

      }

    }

  }

}