内容观察器如何在删除文件时工作?

4

我是Android开发的新手,我在追踪像音频、视频、图片等被删除的文件方面遇到了麻烦。我想获取所有删除文件的详细信息,并将其移动到一个单独的文件夹中。

2个回答

1
在Android中,文件通过内容提供者进行管理。对于每个文件,在内容提供者中都有一个索引,并且我们使用游标来访问它们。您可以使用游标跟踪内容提供程序中的索引,并将其移动到其他位置并更新内容提供程序。

请详细解释... - Mudit Mishra
我也遇到了同样的问题。如果您有代码,请解释一下。 - Atul Bhardwaj

0
// Defines selection criteria for the rows you want to delete
String mSelectionClause = UserDictionary.Words.APP_ID + " LIKE ?";
String[] mSelectionArgs = {"user"};

// Defines a variable to contain the number of rows deleted
int mRowsDeleted = 0;

...

// Deletes the words that match the selection criteria
mRowsDeleted = getContentResolver().delete(
    UserDictionary.Words.CONTENT_URI,   // the user dictionary content URI
    mSelectionClause                    // the column to select on
    mSelectionArgs                      // the value to compare to
);

欲了解更多详情,请访问以下链接以了解内容提供程序:

http://developer.android.com/guide/topics/providers/content-provider-basics.html


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接