简体   繁体   English

如何在android sqlite数据库中存储文件

[英]how to store a file in android sqlite database

i want to save a file in a sqlite android database , first of all i choose the file by a folder explorer that i already made it now im stuck how to save this file in the database and display it in another activity like a menu of files.我想在 sqlite android 数据库中保存一个文件,首先我通过文件夹资源管理器选择文件,我现在已经创建了它,我卡住了如何将此文件保存在数据库中并将其显示在另一个活动中,如文件菜单.

 <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>

您需要读取文件以填充字节数组,然后将其存储到 db 表中的 BLOB 字段中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM