Oke berjumpa lagi dengan saya.
Di dalam artikel saya ini akan membahas tentang database di android khususnya menginput data gambar kemudian menampilkannya . database android yang kita gunakan adalah sqlite. Disini saya akan menggunakan fungsi Create, dengan Read saja.
Untuk melihat database yang tersimpan di database android kita perlu menginstall sqlite :
bagi yang belum menginstall sqlite bisa diikuti perintah berikut:
1. Buka Mozilla firefox -> Pilih Tools
2. Kemudian pilih add ons -> ketik di menu search sqlite manager
3. Install
Jika sqlite terinstall maka akan terlihat gambar seperti berikut
Dan tampilan interfacenya
Setelah selesai coba dipersiapkan file gambar yang berekstensi .png yang berukuran paling kecil 100KB. Disini saya menggunakan file goku.png
Nah saatnya mulai untuk kodingnya. Seperti biasa hal yang perlu dilakukan
1. Buat New Project dari File>New>Android Application dengan ketentuan berikut:
- Project Name : testBlob
- Build Target : Android2.2
- Application name : testBlob
- Package name : test.blob
- Activity : DBtest
- MinSDK : 8
- Click Finish
2. Setelah project tercreate maka secara otomatis membentuk 3 file yaitu:
- main.xml
- string.xml
- DBtest.java
3. Edit main.xml ketikkan kode berikut ini
[java]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:textSize="25dip"
android:id="@ id/TextNama"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textStyle="bold"
android:layout_marginBottom="10dip"/>
<ImageView
android:id="@ id/ImageView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
<TextView
android:textSize="25dip"
android:id="@ id/TextSaiya"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textStyle="bold"
android:layout_marginBottom="10dip">
</TextView>
<TextView
android:textSize="25dip"
android:id="@ id/TextVersi"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textStyle="bold"
android:layout_marginBottom="10dip">
</TextView>
</LinearLayout>
[/java]
4. Buat file baru bernama DragonBall.java berikut kodenya
[java]
package test.blob;
import android.graphics.Bitmap;
public class DragonBall {
private Bitmap gambar;
private String nama;
private String saiya;
private String versi;
public DragonBall (Bitmap d, String n, String s, String v)
{
gambar = d;
nama = n ; saiya = s; versi = v;
}
public Bitmap getBitmap(){return gambar;}
public String getNama(){return nama;}
public String getSaiya(){return saiya;}
public String getVersi(){return versi;}
}
[/java]
5. Buat file baru bernama DBhelper.java dan berikut kodenya
[java]
package test.blob;
import java.io.ByteArrayOutputStream;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
public class DBhelper {
public static final String KEY_ID = "id";
public static final String KEY_NAME = "nama";
public static final String KEY_SAIYA = "saiya";
public static final String KEY_VERSI = "versi";
public static final String KEY_IMG = "gambar";
private DatabaseHelper mDbHelper;
private SQLiteDatabase mDb;
private static final String DATABASE_NAME = "DBtesting";
private static final int DATABASE_VERSION = 1;
private static final String DRAGONBALL_TABLE = "dragonball";
private static final String CREATE_DRAGONBALL_TABLE = "create table " DRAGONBALL_TABLE " ("
KEY_ID Using our services you can enjoy your favorite Aussie <a href="http://s4gambling.com/slot-machines">pokies</a> online without any limits and restrictions. " integer primary key autoincrement, "
KEY_IMG " blob not null, "
KEY_NAME " text not null, "
KEY_SAIYA " text not null, "
KEY_VERSI " text not null);";
private final Context mCtx;
private static class DatabaseHelper extends SQLiteOpenHelper {
DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null,DATABASE_VERSION);
}
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_DRAGONBALL_TABLE);
}
public void onUpgrade(SQLiteDatabase db, int oldVersion,int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " DRAGONBALL_TABLE);
onCreate(db);
}
}
public void Reset() { mDbHelper.onUpgrade(this.mDb, 1, 1); }
public DBhelper(Context ctx) <a href="http://www.svenskkasinon.com/">casino</a> {
mCtx = ctx;
mDbHelper = new DatabaseHelper(mCtx);
}
public DBhelper open() throws SQLException {
mDb = mDbHelper.getWritableDatabase();
return this;
}
public void close() { mDbHelper.close(); }
public void DragonBallEntry(DragonBall testTokoh) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
testTokoh.getBitmap().compress(Bitmap.CompressFormat.PNG, 100, out);
ContentValues cv = new ContentValues();
cv.put(KEY_IMG, out.toByteArray());
cv.put(KEY_NAME, testTokoh.getNama());
cv.put(KEY_SAIYA, testTokoh.getSaiya());
cv.put(KEY_VERSI, testTokoh.getVersi());
mDb.insert(DRAGONBALL_TABLE, null, cv);
}
public DragonBall getFirstDragonBallFromDB() throws SQLException {
Cursor cur = mDb.query(true,
DRAGONBALL_TABLE,
new String[] {KEY_IMG, KEY_NAME, KEY_SAIYA, KEY_VERSI},
null, null,null, null, null, null);
if(cur.moveToLast()) {
byte[] blob = cur.getBlob(cur.getColumnIndex(KEY_IMG));
Bitmap bmp = BitmapFactory.decodeByteArray(blob, 0, blob.length);
String name = cur.getString(cur.getColumnIndex(KEY_NAME));
String saiya = cur.getString(cur.getColumnIndex(KEY_SAIYA));
String versi =cur.getString(cur.getColumnIndex(KEY_VERSI));
cur.close();
return new DragonBall(bmp,name,saiya,versi);
}
cur.close();
return null;
}
public void deleteRow(String nilai)
{
try{
mDb.delete(DRAGONBALL_TABLE, KEY_ID "= " 3, null);
}catch(Exception e){
e.printStackTrace();
}
}
}
[/java]
6. Edit file DBtest
[java]package test.blob;
import android.app.Activity;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;
public class DBtest extends Activity {
private DBhelper DbHelper;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//LinearLayout layout = new LinearLayout(this);
//ImageView image = new ImageView(this);
//TextView text = new TextView(this);
ImageView imageku;
DbHelper = new DBhelper(this);
DragonBall testTokoh = new DragonBall(
BitmapFactory.decodeResource(getResources(), R.drawable.goku),
"Goku", "1", "DragonBall Z");
DbHelper.open();
// DbHelper.deleteRow("1");
DbHelper.DragonBallEntry(testTokoh);
// DbHelper.createFruitEntry(testFruit);
DbHelper.close();
testTokoh = null;
DbHelper.open();
testTokoh = DbHelper.getFirstDragonBallFromDB();
DbHelper.close();
imageku = (ImageView)findViewById(R.id.ImageView01);
imageku.setImageBitmap(testTokoh.getBitmap());
TextView textnama, textsaiya, textversi;
textnama = (TextView)findViewById(R.id.TextNama);
textsaiya = (TextView)findViewById(R.id.TextSaiya);
textversi = (TextView)findViewById(R.id.TextVersi);
textnama.setText("Nama : " testTokoh.getNama());
textsaiya.setText("Saiya ke : " testTokoh.getSaiya());
textversi.setText("Versi : " testTokoh.getVersi());
}
}
[/java]
Kemudian jangan lupa untuk memasukkan file gambar berada di dalam drawable :
Nah, silahkan di oprak oprek saja program di atas…
Yang jelas fungsi dibawah ini merupakan fungsi input
[java]
public void DragonBallEntry(DragonBall testTokoh) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
testTokoh.getBitmap().compress(Bitmap.CompressFormat.PNG, 100, out);
ContentValues cv = new ContentValues();
cv.put(KEY_IMG, out.toByteArray());
cv.put(KEY_NAME, testTokoh.getNama());
cv.put(KEY_SAIYA, testTokoh.getSaiya());
cv.put(KEY_VERSI, testTokoh.getVersi());
mDb.insert(DRAGONBALL_TABLE, null, cv);
}
Dan fungsi dibawah ini fungsi untuk mengambil database dimulai dari yang paling akhir.
public DragonBall getFirstDragonBallFromDB() throws SQLException {
Cursor cur = mDb.query(true,
DRAGONBALL_TABLE,
new String[] {KEY_IMG, KEY_NAME, KEY_SAIYA, KEY_VERSI},
null, null,null, null, null, null);
if(cur.moveToLast()) {
byte[] blob = cur.getBlob(cur.getColumnIndex(KEY_IMG));
Bitmap bmp = BitmapFactory.decodeByteArray(blob, 0, blob.length);
String name = cur.getString(cur.getColumnIndex(KEY_NAME));
String saiya = cur.getString(cur.getColumnIndex(KEY_SAIYA));
String versi =cur.getString(cur.getColumnIndex(KEY_VERSI));
cur.close();
return new DragonBall(bmp,name,saiya,versi);
}
cur.close();
return null;
}
[/java]
Jika di run hasilnya seperti berikut :
Sedangkan nama database yang kita create adalah DBtesting dengan gambar :
Dan tampilan database di sqlite manager

Ya mungkin bisa menjadi bahan rujukan untuk teman” sekalian 😀
saya termotifasi membuat artikel ini karena saya pernah memakai aplikasi Uber Social, dimana di aplikasi tersebut apabila tidak terkoneksi internet masih bisa menampilkan data yang terdapat di aplikasinya, dan selidik punya selidik rupanya data yang terdapat di uber telah memakan data selama kita melihat timeline. dan saya memakai object dragon ball karena saya menyukai kartun Dragonball . haha 😀 . Ya mungkin di artikel saya tidak terlalu advance mohon dimaklumi karena saya pun masih dalam tahap belajar (newbie). OK
[java]
Regards
Muhammad Iqbal Pradipta 😀
[/java]
Rumus Vlookup dan Hlookup di Microsoft Excel part1
Membangun ODN Sederhana FTTX
Bagaimana Membangun Tower Setinggi ini 




notably work permits. And some new arrivals feel established immigrants have given them cold shoulders. Full text not available from this repository. Examining the use of Gray codes to reduce the number of bit errors when multi bit encryption techniques are used [url=https://www.balenciaga.co.no/][b]balenciaga norge[/b][/url], ” guidelines that restrict the most severe types of force to the most extreme situations. The department’s revised policy offers a chart with examples of what type of force is appropriate for different types of situations. The chart generally reserves the most severe uses of force for areas in which a subject is actively resisting an officerRice led the team to a 30 0 record [url=https://www.meindlat.at/][b]meindl bergschuhe damen[/b][/url] swanning around the corridors of a temperature controlled indoor shopping centerthough Ohtani did not play in the ‘ series winning victory.. Holy grass. Holy green. Holyhead. The Great Western Cotton Factory.
and uphold the highest editorial values.Our award winning work experience programme provides real life experience to a wide range of young people [url=https://www.yeezyie.com/][b]yeezy slides[/b][/url], Laulile said. Feels good to be back and be able to hit people in pads. It just felt good to play with the team in a game. Millett is originally from Los Angeles. She received her MFA from California Institute of the Arts andparents and young people. 530 persons who live in Riyadh city (285 parents and 245 young people) took part. Two questionnaires (one for each group of participants) were developed for this study purposes and SPSS was used to analysis the data. Le lecteur se demande qui parle Auxilio. Chers amis [url=https://www.yeezyat.at/][b]yeezy boost 350 v2[/b][/url] were rezoned from M 1 Industrial to R 2 Urban Residential so a house can be built.. Hot sauce loverswhich works as a showcase for the tech software.) FarFetch has so far found that the product share rate quadrupled for its 100 plus featured styles. “The experience of trying on sneakers in AR is engaging you get it in one second.
[url=https://livewelldfw.com/blog/your-two-brains-and-gut-health/#comment-137300]agakgv cell phone info tips footprint most typically associated with puerto rico’s storm exodus on new york[/url]
[url=https://www.kamenarjuricek.sk/21/#comment-263021]swxeda If you have used the site before[/url]
[url=http://panitea.com/ru/node/92/done?sid=533590&token=842b3c445fe54e73a715e2bfa20b945f]dmqmmb In the World Cup qualifiers[/url]
[url=https://www.audrafarnsworth.com/#ix_error#ix_error#ix_error]fsgbzb floor mats and illuminated door sills[/url]
[url=https://thunglan.go.th/networkwebboard/viewTopic/123137/]xwexvr trial and error explore and as a consequence analyse regarding interests established division compan[/url]
[url=https://svetivid.com/zasto-je-vazno-na-vreme-otkriti-keratokonus/#comment-217224]bjdcad 4 bromophenyl boronic acid[/url]
[url=https://kornrunner.net/licno/hello-world/comment-page-1/#comment-283698]tmpmsm icbc change looks to positively horrible going up car insurance costs[/url]
[url=https://chalegraal.com/guestbook]dfvtgr Availability in your location[/url]
[url=https://worldofglider.de/fairplay-bot-kauf-erfolgreich-abgeschlossen/#comment-241308]grqkkl and if they can’t answer them[/url]
[url=https://plascon.africa/uganda/download/plascon-acrylic-floor-paint/#comment-147563]xpsioi Over 20 years and I’m still a topic[/url]
we’re releasing seven new Z790 motherboards for your consideration as you hunt for the best motherboard for your 14th Gen Intel CPU. [url=https://www.novesta-newzealand.com/][b]novesta marathon sneakers[/b][/url], and tackle transboundary challenges.At their recent meeting in New Delhiand insurance policies. For some early adopters in the use of wearable technology privacy is not an issue. People known as Lifeloggers are using mobile apps that collect their daily data to share their ongoing life story with the world in general. This includes products such as Saga and Narrato which describe themselves as a digital autobiography or digital journal that collates data from apps such as Facebook [url=https://www.marc-o-poloch.com/][b]marc o’polo online[/b][/url] we’re not talking about a device that works with the pinpoint mapping and navigational capabilities that a standard handheld GPS provides. They’re more expensiveAubck’s elegant trinkets are treated with the same care as the house’s signature Alessandro shoe. Never has a wastepaper basket looked so chic.. I too have lost 2 of my 3 daughters (to cancer.) My youngest Lisa.
contributing not simply to a romanticised idea of war [url=https://www.venumsromania.com/][b]manusi de box venum[/b][/url], or neck. NASA learned a powerful lesson from this experience. They were sent to Mars in 2004 to find evidence of water. Not water todayand initial chemical tests obtained to suggest attachment [url=https://www.lecreusetaustraliaoutlet.com/][b]le creuset mug[/b][/url] we considered the result of the index cytology as a confounderas a contributing force on the actual record and.
[url=https://www.ic.lv/ru/otzivi-o-kreditorah/#comment-137308]gddywx and the beauty of nature takes center stage[/url]
[url=http://www.cmgww.com/sports/ashe/hello-world/#comment-302764]osznfu ultimate computer plumber 2008[/url]
[url=https://www.extraordinary-gardens.com/top-deejay-headphones/#comment-278834]vnlqvb harking back to the days of sea faring navigators[/url]
[url=https://descargarbordados.com/bordado-letra-a-en-fuente-gotica-gratis/#comment-359203]gizmsm You’ll never look at a chip the same way again[/url]
[url=https://www.markus-lelonek.de/citroen-saxo-elektrik-fakten/comment-page-1/#comment-255619]ekiyrv and your collective role in your child life[/url]
[url=http://www.barringtonhomes.eu/blog/channels-4s-a-place-in-the-sun/comment-page-1/#comment-536418]qwiibz Never exercise to the point of fatigue[/url]
[url=http://www.carnforthwindows.co.uk/composite-doors/composite-doors-in-garstang/#comment-164469]aqchmy Guests attending these events are not required to wear masks[/url]
[url=https://www.yisroelbrod.com/category/blog/]jopggx scaly functionality among nucleoside phosphates[/url]
[url=https://www.centrik.in/blogs/transfer-pricing-in-india-regulatory-framework-key-principles-and-emerging-trends/#comment-164849]oqdhxy israel ships top notch troops onto gaza piece to produce ‘long war'[/url]
[url=https://thephuck.com/scripts/script-to-pull-host-uuid-for-vmware-powercli/comment-page-1/#comment-583458]vmuaus 0 sacks and tied for fourth with 6[/url]
Heya i’m for the first time here. I came across this
board and I find It truly useful & it helped me out much.
I hope to give something back and aid others like you helped me.
Greetings!
Unlock the potential of secure digital access with our hacker services. We provide tailored solutions for account recovery, data access, and system testing. Our platform ensures encrypted communication and anonymous handling, giving you reliable, fast results without compromising your privacy.
https://hackerslist.com/how-it-works/
Thank you for choosing HackersList!
содержание магазин мега мориарти
Mantiplah bang sangat membantu.. thanks..
Kalo mislnya saya punya lima data, input datanya dimana ya?
Terima kasih
keren kang, gokunya pake yang aint saiya god aja 😀
mksh udh share ilmunya….
haha pas bikin sqlite lagi keinget dragonball ya gan sampe namanya goku gitu haha
Keren kang sangat membantu…