S
sugg1
Neues Mitglied
- 0
Hallo,
ich habe eine kleine App geschrieben, mit der man verschieden Rezepte speichern kann. Das hat bisher einwandfrei funktioniert. Nun wollte ich diese App um ein "Bild" erweitern.
Leider stürzt die App nun ab, wenn ich auf den Speichern Button drücke, egal ob ich ein Foto mache oder nicht.
Hier der Quellcode möglichst kurz:
Datenbank erstellen:
Daten schreiben:
Getter- und Setter Methoden der Klasse Rezept
Methoden zum Umwandeln von Drawables zu Byte-Arrays in der Klasse ImageUtils
Kamerafunktion in der Klasse MainActivity4:
(entsprechender Button: androidnClick="process")
Der Speichern Button in der MainActivity4 schreibt die Daten mit instertData() in die Datenbank und hier kommt die Fehlermeldung
Logcat Ausgabe:
[FONT="]06-23 15:54:35.243: W/IInputConnectionWrapper(17741): showStatusIcon on inactive InputConnection[/FONT]
[FONT="]06-23 15:54:44.352: D/dalvikvm(17741): GC_FOR_ALLOC freed 126K, 10% free 9760K/10759K, paused 50ms, total 51ms[/FONT]
[FONT="]06-23 15:54:44.542: I/dalvikvm-heap(17741): Grow heap (frag case) to 29.095MB for 19660816-byte allocation[/FONT]
[FONT="]06-23 15:54:44.562: D/dalvikvm(17741): GC_CONCURRENT freed 24K, 4% free 28936K/30023K, paused 3ms+2ms, total 20ms[/FONT]
[FONT="]06-23 15:54:44.562: D/dalvikvm(17741): WAIT_FOR_CONCURRENT_GC blocked 16ms[/FONT]
[FONT="]06-23 15:54:47.055: D/AndroidRuntime(17741): Shutting down VM[/FONT]
[FONT="]06-23 15:54:47.055: W/dalvikvm(17741): threadid=1: thread exiting with uncaught exception (group=0x418472a0)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): FATAL EXCEPTION: main[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): java.lang.NumberFormatException: Invalid int: ""[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at java.lang.Integer.invalidInt(Integer.java:138)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at java.lang.Integer.parseInt(Integer.java:359)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at java.lang.Integer.parseInt(Integer.java:332)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at com.example.favoureat.MainActivity4$2.onClick(MainActivity4.java:106)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at android.view.View.performClick(View.java:4162)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at android.view.View$PerformClick.run(View.java:17082)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at android.os.Handler.handleCallback(Handler.java:615)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at android.os.Handler.dispatchMessage(Handler.java:92)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at android.os.Looper.loop(Looper.java:137)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at android.app.ActivityThread.main(ActivityThread.java:4867)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at java.lang.reflect.Method.invokeNative(Native Method)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at java.lang.reflect.Method.invoke(Method.java:511)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at dalvik.system.NativeStart.main(Native Method)[/FONT]
[FONT="]06-23 15:54:55.953: I/Process(17741): Sending signal. PID: 17741 SIG: 9[/FONT]
So, ich hoffe da blickt noch jemand durch und kann helfen. Ich denke dass es nur an einer Kleinigkeit liegt?
Gruß sugg1
ich habe eine kleine App geschrieben, mit der man verschieden Rezepte speichern kann. Das hat bisher einwandfrei funktioniert. Nun wollte ich diese App um ein "Bild" erweitern.
Leider stürzt die App nun ab, wenn ich auf den Speichern Button drücke, egal ob ich ein Foto mache oder nicht.
Hier der Quellcode möglichst kurz:
Datenbank erstellen:
Code:
[B][COLOR=#7F0055][FONT=Consolas]private[/FONT][/COLOR][/B][B][COLOR=#7F0055][FONT=Consolas]static[/FONT][/COLOR][/B][B][COLOR=#7F0055][FONT=Consolas]final[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] String [/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]CREATE_DB[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas] = [/FONT][/COLOR][COLOR=#2A00FF][FONT=Consolas]"CREATE TABLE "[/FONT][/COLOR][COLOR=black][FONT=Consolas] + [/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]TABLE_NAME[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas] + [/FONT][/COLOR][COLOR=#2A00FF][FONT=Consolas]" (_id INTEGER PRIMARY KEY, name VARCHAR(255), zutaten VARCHAR(255), zubereitung VARCHAR(255), person INTEGER(10), pictureData BLOB);"[/FONT][/COLOR][COLOR=black][FONT=Consolas];[/FONT][/COLOR]
Code:
[B][COLOR=#7F0055][FONT=Consolas]public[/FONT][/COLOR][/B][B][COLOR=#7F0055][FONT=Consolas]void[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] insertData([/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]int[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] id,String name, String zutaten, String zubereitung, [/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]int[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] person, [/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]byte[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas][] pictureData)[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] {[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]try[/FONT][/COLOR][/B]
[COLOR=black][FONT=Consolas] {[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] SQLiteDatabase db = getWritableDatabase();[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] ContentValues values = [/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]new[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] ContentValues();[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] values.put([/FONT][/COLOR][COLOR=#2A00FF][FONT=Consolas]"_id"[/FONT][/COLOR][COLOR=black][FONT=Consolas], id);[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] values.put([/FONT][/COLOR][COLOR=#2A00FF][FONT=Consolas]"name"[/FONT][/COLOR][COLOR=black][FONT=Consolas], name);[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] values.put([/FONT][/COLOR][COLOR=#2A00FF][FONT=Consolas]"zutaten"[/FONT][/COLOR][COLOR=black][FONT=Consolas], zutaten);[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] values.put([/FONT][/COLOR][COLOR=#2A00FF][FONT=Consolas]"zubereitung"[/FONT][/COLOR][COLOR=black][FONT=Consolas], zubereitung);[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] values.put([/FONT][/COLOR][COLOR=#2A00FF][FONT=Consolas]"person"[/FONT][/COLOR][COLOR=black][FONT=Consolas], person);[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] values.put([/FONT][/COLOR][COLOR=#2A00FF][FONT=Consolas]"pictureData"[/FONT][/COLOR][COLOR=black][FONT=Consolas], Rezept.[I]getPictureData[/I]());[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] db.insert([/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]TABLE_NAME[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas],[/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]null[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas],values);[/FONT][/COLOR]
[COLOR=black][FONT=Consolas]}[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]catch[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas](SQLiteException e)[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] {[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] Log.[I]e[/I]([/FONT][/COLOR][COLOR=#2A00FF][FONT=Consolas]"DB"[/FONT][/COLOR][COLOR=black][FONT=Consolas], [/FONT][/COLOR][COLOR=#2A00FF][FONT=Consolas]"Fehler"[/FONT][/COLOR][COLOR=black][FONT=Consolas], e);[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] }[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] }[/FONT][/COLOR]
Getter- und Setter Methoden der Klasse Rezept
Code:
[B][COLOR=#7F0055][FONT=Consolas]public[/FONT][/COLOR][/B][B][COLOR=#7F0055][FONT=Consolas]void[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] setPictureData([/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]byte[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas][] pictureData) {[/FONT][/COLOR]
[I][COLOR=#0000C0][FONT=Consolas]pictureDataDrawable[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas] = ImageUtils.[I]byteToDrawable[/I](pictureData);[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] }[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]public[/FONT][/COLOR][/B][B][COLOR=#7F0055][FONT=Consolas]static[/FONT][/COLOR][/B][B][COLOR=#7F0055][FONT=Consolas]byte[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas][] getPictureData(){[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]return[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] ImageUtils.[I]drawableToByteArray[/I]([/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]pictureDataDrawable[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas]);[/FONT][/COLOR]
Code:
[B][COLOR=#7F0055][FONT=Consolas]public[/FONT][/COLOR][/B][B][COLOR=#7F0055][FONT=Consolas]static[/FONT][/COLOR][/B][B][COLOR=#7F0055][FONT=Consolas]byte[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas][] drawableToByteArray(Drawable d) {[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]if[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] (d != [/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]null[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas]) {[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] Bitmap imageBitmap = ((BitmapDrawable) d).getBitmap();[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] ByteArrayOutputStream baos = [/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]new[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] ByteArrayOutputStream();[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] imageBitmap.compress(Bitmap.CompressFormat.[/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]PNG[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas], 100, baos);[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]byte[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas][] byteData = baos.toByteArray();[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]return[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] byteData;[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] } [/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]else[/FONT][/COLOR][/B]
[B][COLOR=#7F0055][FONT=Consolas]return[/FONT][/COLOR][/B][B][COLOR=#7F0055][FONT=Consolas]null[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas];[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] }[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]public[/FONT][/COLOR][/B][B][COLOR=#7F0055][FONT=Consolas]static[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] Drawable byteToDrawable([/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]byte[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas][] data) {[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]if[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] (data == [/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]null[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas])[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]return[/FONT][/COLOR][/B][B][COLOR=#7F0055][FONT=Consolas]null[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas];[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]else[/FONT][/COLOR][/B]
[B][COLOR=#7F0055][FONT=Consolas]return[/FONT][/COLOR][/B][B][COLOR=#7F0055][FONT=Consolas]new[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] [U]BitmapDrawable[/U][U](BitmapFactory.[I]decodeByteArray[/I](data, 0, data.[/U][/FONT][/COLOR][U][COLOR=#0000C0][FONT=Consolas]length[/FONT][/COLOR][/U][U][COLOR=black][FONT=Consolas]))[/FONT][/COLOR][/U][COLOR=black][FONT=Consolas];[/FONT][/COLOR]
[COLOR=black][FONT=Consolas]}[/FONT][/COLOR]
(entsprechender Button: androidnClick="process")
Code:
[B][COLOR=#7F0055][FONT=Consolas]public[/FONT][/COLOR][/B][B][COLOR=#7F0055][FONT=Consolas]void[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] process(View v) [/FONT][/COLOR][COLOR=#3F7F5F][FONT=Consolas]// [U]Kamerafunktion[/U][/FONT][/COLOR]
[COLOR=black][FONT=Consolas] {[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] Intent intent = [/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]new[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] Intent(MediaStore.[/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]ACTION_IMAGE_CAPTURE[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas]);[/FONT][/COLOR]
[COLOR=#0000C0][FONT=Consolas]imageFile[/FONT][/COLOR][COLOR=black][FONT=Consolas] = [/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]new[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] File(Environment.[I]getExternalStoragePublicDirectory[/I](Environment.[/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]DIRECTORY_PICTURES[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas]),[/FONT][/COLOR][COLOR=#2A00FF][FONT=Consolas]"test.jpg"[/FONT][/COLOR][COLOR=black][FONT=Consolas]);[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] Uri tempuri = Uri.[I]fromFile[/I]([/FONT][/COLOR][COLOR=#0000C0][FONT=Consolas]imageFile[/FONT][/COLOR][COLOR=black][FONT=Consolas]);[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] intent.putExtra(MediaStore.[/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]EXTRA_OUTPUT[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas], tempuri);[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] intent.putExtra(MediaStore.[/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]EXTRA_VIDEO_QUALITY[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas], 1);[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] startActivityForResult(intent, 0);[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] }[/FONT][/COLOR]
[COLOR=#646464][FONT=Consolas]@Override[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]protected[/FONT][/COLOR][/B][B][COLOR=#7F0055][FONT=Consolas]void[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] onActivityResult([/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]int[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] requestCode, [/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]int[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] resultCode, Intent data)[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] {[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]if[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas](requestCode == 0)[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] {[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]switch[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] (resultCode)[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] {[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]case[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] Activity.[/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]RESULT_OK[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas]:[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]if[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas]([/FONT][/COLOR][COLOR=#0000C0][FONT=Consolas]imageFile[/FONT][/COLOR][COLOR=black][FONT=Consolas].exists())[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] {[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] Toast.[I]makeText[/I]([/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]this[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas], [/FONT][/COLOR][COLOR=#2A00FF][FONT=Consolas]"The File was saved at: "[/FONT][/COLOR][COLOR=black][FONT=Consolas] + [/FONT][/COLOR][COLOR=#0000C0][FONT=Consolas]imageFile[/FONT][/COLOR][COLOR=black][FONT=Consolas].getAbsolutePath(), Toast.[/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]LENGTH_LONG[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas]).show();[/FONT][/COLOR]
[I][COLOR=#0000C0][FONT=Consolas]myBitmap[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas] = BitmapFactory.[I]decodeFile[/I]([/FONT][/COLOR][COLOR=#0000C0][FONT=Consolas]imageFile[/FONT][/COLOR][COLOR=black][FONT=Consolas].getAbsolutePath());[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] ImageView iv = (ImageView)findViewById(R.id.[/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]imageView1[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas]);[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] iv.setImageBitmap([/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]myBitmap[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas]);[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] }[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]else[/FONT][/COLOR][/B]
[COLOR=black][FONT=Consolas] {[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] Toast.[I]makeText[/I]([/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]this[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas], [/FONT][/COLOR][COLOR=#2A00FF][FONT=Consolas]"File was not saved"[/FONT][/COLOR][COLOR=black][FONT=Consolas], Toast.[/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]LENGTH_LONG[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas]).show();[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] }[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]break[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas];[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]case[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] Activity.[/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]RESULT_CANCELED[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas]:[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]break[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas];[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] }[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] }[/FONT][/COLOR]
[COLOR=black][FONT=Consolas] }[/FONT][/COLOR]
Code:
[B][COLOR=#7F0055][FONT=Consolas]final[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] Datenbank database = [/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]new[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] Datenbank([/FONT][/COLOR][B][COLOR=#7F0055][FONT=Consolas]this[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas]); [/FONT][/COLOR][COLOR=#3F7F5F][FONT=Consolas]// [U]für[/U] [U]Datenbankfunktion[/U][/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]final[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] EditText et1 = (EditText)findViewById(R.id.[/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]textView1[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas]); [/FONT][/COLOR][COLOR=#3F7F5F][FONT=Consolas]// Name [U]des[/U] [U]Rezepts[/U][/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]final[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] TextView tv1 = (TextView)findViewById(R.id.[/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]textView2[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas]); [/FONT][/COLOR][COLOR=#3F7F5F][FONT=Consolas]// [U]Zutaten[/U][/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]final[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] EditText et2 = (EditText)findViewById(R.id.[/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]textView6[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas]); [/FONT][/COLOR][COLOR=#3F7F5F][FONT=Consolas]// [U]Zubereitung[/U][/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]final[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] EditText et3 = (EditText)findViewById(R.id.[/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]textView7[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas]); [/FONT][/COLOR][COLOR=#3F7F5F][FONT=Consolas]// [U]Personen[/U][/FONT][/COLOR]
[B][COLOR=#7F0055][FONT=Consolas]final[/FONT][/COLOR][/B][COLOR=black][FONT=Consolas] ImageView iv1 = (ImageView)findViewById(R.id.[/FONT][/COLOR][I][COLOR=#0000C0][FONT=Consolas]imageView1[/FONT][/COLOR][/I][COLOR=black][FONT=Consolas]); [/FONT][/COLOR][COLOR=#3F7F5F][FONT=Consolas]// [U]Bild[/U][/FONT][/COLOR][COLOR=black][FONT=Consolas]
database.insertData([/FONT][/COLOR][COLOR=#0000C0][FONT=Consolas]rezept_id[/FONT][/COLOR][COLOR=black][FONT=Consolas], et1.getText().toString(), tv1.getText().toString(), et2.getText().toString(), Integer.[I]parseInt[/I](et3.getText().toString()), ImageUtils.[I]drawableToByteArray[/I](iv1.getDrawable()));[/FONT][/COLOR]
Logcat Ausgabe:
[FONT="]06-23 15:54:35.243: W/IInputConnectionWrapper(17741): showStatusIcon on inactive InputConnection[/FONT]
[FONT="]06-23 15:54:44.352: D/dalvikvm(17741): GC_FOR_ALLOC freed 126K, 10% free 9760K/10759K, paused 50ms, total 51ms[/FONT]
[FONT="]06-23 15:54:44.542: I/dalvikvm-heap(17741): Grow heap (frag case) to 29.095MB for 19660816-byte allocation[/FONT]
[FONT="]06-23 15:54:44.562: D/dalvikvm(17741): GC_CONCURRENT freed 24K, 4% free 28936K/30023K, paused 3ms+2ms, total 20ms[/FONT]
[FONT="]06-23 15:54:44.562: D/dalvikvm(17741): WAIT_FOR_CONCURRENT_GC blocked 16ms[/FONT]
[FONT="]06-23 15:54:47.055: D/AndroidRuntime(17741): Shutting down VM[/FONT]
[FONT="]06-23 15:54:47.055: W/dalvikvm(17741): threadid=1: thread exiting with uncaught exception (group=0x418472a0)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): FATAL EXCEPTION: main[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): java.lang.NumberFormatException: Invalid int: ""[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at java.lang.Integer.invalidInt(Integer.java:138)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at java.lang.Integer.parseInt(Integer.java:359)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at java.lang.Integer.parseInt(Integer.java:332)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at com.example.favoureat.MainActivity4$2.onClick(MainActivity4.java:106)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at android.view.View.performClick(View.java:4162)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at android.view.View$PerformClick.run(View.java:17082)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at android.os.Handler.handleCallback(Handler.java:615)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at android.os.Handler.dispatchMessage(Handler.java:92)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at android.os.Looper.loop(Looper.java:137)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at android.app.ActivityThread.main(ActivityThread.java:4867)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at java.lang.reflect.Method.invokeNative(Native Method)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at java.lang.reflect.Method.invoke(Method.java:511)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)[/FONT]
[FONT="]06-23 15:54:47.055: E/AndroidRuntime(17741): at dalvik.system.NativeStart.main(Native Method)[/FONT]
[FONT="]06-23 15:54:55.953: I/Process(17741): Sending signal. PID: 17741 SIG: 9[/FONT]
So, ich hoffe da blickt noch jemand durch und kann helfen. Ich denke dass es nur an einer Kleinigkeit liegt?
Gruß sugg1