小编che*_*mar的帖子

如何将音频/视频文件存储到 android 中的 SQLite 数据库中。?

我是开发新手,通过将图像转换为字节数组并将其存储到 BLOB 中的 SQLite 数据库(在下面的代码中找到),我成功地将图像存储到数据库中。但是我不知道如何将音频/视频存储到数据库中,任何人都可以帮助我 PLZ ...

 public void getImage(View view){
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_GET_CONTENT);
    intent.setType("image/* video/*");
    startActivityForResult(Intent.createChooser(intent, "select picture"), 1);

}

public void onActivityResult(int requestCode, int resultCode, Intent data){
    if(resultCode == RESULT_OK){
        Uri imageUri = data.getData();
        String imagePath = getPath(imageUri);

        image1.setVisibility(View.VISIBLE);

        image1.setImageURI(imageUri);
        Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
        Toast.makeText(getApplicationContext(), ""+bitmap, Toast.LENGTH_SHORT).show();
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
        img = byteArrayOutputStream.toByteArray();
    }
}

 public String getPath(Uri uri) {
    String[] projection = { MediaStore.Images.Media.DATA };
    Cursor cursor = managedQuery(uri, …
Run Code Online (Sandbox Code Playgroud)

sqlite android sqliteopenhelper android-sqlite android-database

8
推荐指数
1
解决办法
1万
查看次数

如何在android中将视频/音频文件转换为字节数组,反之亦然。?

我正在尝试将音频/视频转换为字节数组,反之亦然,使用下面的代码可以将音频/视频文件转换为字节数组(见下面的代码),但无法转换大文件(超过 50MB 的文件)是否有任何限制。 ? 如何将字节数组转换为音频/视频文件。?请帮帮我。

public byte[] convert(String path) throws IOException {

    FileInputStream fis = new FileInputStream(path);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    byte[] b = new byte[1024];

    for (int readNum; (readNum = fis.read(b)) != -1;) {
        bos.write(b, 0, readNum);
    }

    byte[] bytes = bos.toByteArray();

    return bytes;
}
Run Code Online (Sandbox Code Playgroud)

请帮忙得到结果

android android-layout android-database

4
推荐指数
1
解决办法
2万
查看次数

如何检查Android应用程序中的Facebook登录状态.

当我检查以前的答案时,他们建议使用Session来检查Facebook登录状态,但是在新版本中删除了该类,任何人都可以帮我解决这个问题.

我怎样才能找到我当前的登录状态 - facebook API android

android facebook facebook-graph-api facebook-android-sdk android-facebook

4
推荐指数
1
解决办法
4924
查看次数