2016-04-28 15 views
-1

Ich möchte eine Datei in einer SQL-android-Datenbank speichern, vor allem wähle ich die Datei von einem Ordner Explorer, dass ich es bereits jetzt gemacht habe im stecken, wie Sie diese Datei in der speichern Datenbank und zeigen Sie es in einer anderen Aktivität wie einem Menü von Dateien an.Wie man eine Datei in android sqlite Datenbank speichert

<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:id="@+id/textview" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Get File Name From SDCard" 
     android:textSize="18dp" 
     android:gravity="center" 
     android:layout_marginTop="10dp"  
    />  
    <RelativeLayout android:id="@+id/relativeLayout1" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content"> 
     <EditText 
      android:layout_alignParentLeft="true" 
      android:hint="EditText" 
      android:id="@+id/editText" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_marginTop="15dp" 
      android:ems="10" 
      android:inputType="textPersonName" 
      android:layout_toLeftOf="@+id/skipButton" > 
     </EditText> 

     <Button android:text="Browser" 
      android:id="@+id/skipButton" 
      android:textSize="18dp" 
      android:layout_marginTop="10dp" 
      android:layout_alignParentRight="true" 
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:onClick="getfile" > 
     </Button> 
     <Button android:text="Enregistrer" 
      android:id="@+id/saveB" 
      android:textSize="18dp" 
      android:layout_marginTop="10dp" 
      android:layout_alignParentRight="true" 
         android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
      > 
</Button> 
</RelativeLayout> 
</LinearLayout> 
+0

Schreckliche Idee, um Ihre Datenbank mit Dateien aufzublähen. Sie sollten besser Dateipfade speichern. –

+0

Wie kann ich das tun? – Andro

+0

Pfade sind nichts als Strings. –

Antwort

1

Sie müssen Ihre Datei lesen, um ein Bytearray zu füllen, und dann in ein BLOB-Feld in Ihrer db-Tabelle speichern.

Verwandte Themen