5_hafta_örnekleri

blareweyrΛογισμικό & κατασκευή λογ/κού

13 Δεκ 2013 (πριν από 3 χρόνια και 7 μήνες)

58 εμφανίσεις




package

ilker.video;


import

android.app.Activity;

import

android.os.Bundle;

import

android.widget.MediaController;

import

android.widget.VideoView
;


public

class

VideoActivity
extends

Activity {



private

VideoView

video
;




/** Called when the
activity is first created. */


@Override


public

void

onCreate(Bundle savedInstanceState) {


super
.onCreate(savedInstanceState);


setContentView(R.layout.
main
);


video

= (
VideoView
) findViewById(R.id.
videoView1
);


MediaController mediaController =
new

MediaController(
this
);


mediaController.setMediaPlayer(
video
);


video
.setVideoPath(
"http://www.pocketjourney.com/downloads/pj/video/famous.3gp"
);


video
.setMediaController(mediaContro
ller);


video
.requestFocus();


video
.start();


mediaController.show();


}

}



package ilker.veritab;


import java.util.Locale;

import android.app.Activity;

import android.content.ContentValues;

import
android.database.sqlite.SQLiteDatabase;

import android.database.sqlite.SQLiteException;

import android.os.Bundle;

import android.util.Log;

import android.view.View;

import android.widget.TextView;

import android.widget.Toast;


public class VeritabActivity
extends Activity {


SQLiteDatabase vt;


String yol="/data/data/ilker.veritab/databases/";


String vtad="deneme";



boolean vtkontrol;



long usid;



/** Called when the activity is first created. */


@Override


public void onCreate(Bundle savedIn
stanceState) {


super.onCreate(savedInstanceState);


setContentView(R.layout.main);




vtkontrol=kontrol();


if(!vtkontrol){


vt = openOrCreateDatabase(vtad, SQLiteDatabase.CREATE_IF_NECESSARY, null);


vt.setVersion(1);


vt.setLocale(Locale.getDefault());


vt.setLockingEnabled(true);


final String CREATE_TABLE_USER =


"CREATE TABLE ornek1 (id INTEGER PRIMARY KEY AUTOINCREMENT,ad TEXT
,soyad TEXT);";


vt.execSQL(CREATE_TABLE_USER);


}


else{


vt = SQLiteDatabase.openDatabase(yol+vtad, null, SQLiteDatabase.OPEN_READWRITE);




}


}





private boo
lean kontrol(){




SQLiteDatabase checkDB = null;




try{


String myPath = yol + vtad;


checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);


}catch(SQLiteException e){


//
database does’t exist yet.


}


if(checkDB != null){


checkDB.close();


}


return checkDB != null ? true : false;


}


public void kaydet(View x){



TextView ad,soyad;



ad=(TextView)findViewById(R.id.editText1);



soyad=(TextView)findViewById(R.id.editText2);



ContentValues deger = new ContentValues();



deger.put("ad", ad.getText().toString());


deger.put("soyad", soyad.getText().toString());


try

{


usid = vt.insertOrThrow("ornek1", null, deger);


Toast.makeText(getApplicationContext(), "Kaydınız Yapıldı. ID: "+usid,
Toast.LENGTH_LONG).show();


} catch (Exception e) {


Log.e("insert",e.getMessage());



}






}



}