内容观察者如何处理已删除的文件?

时间:2013-08-08 04:49:09

标签: android contentobserver

我是Android开发的新手,我在跟踪已删除的文件(如音频,视频,图像等)时遇到问题。我想获取已删除文件的所有详细信息,之后我想将删除的文件移到单独的文件夹中。

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分: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