上記のコメントに基づいて:
ループを介してデータベース内のすべての要素を更新できます
残念ながら、データベースからデータを抽出し、何らかのリストに入れ、リストを変更してパスを変更し、変更した値でデータベースを更新する必要があります。
注: これを行う必要があるのは 1 回だけですが、更新するレコードが数千ある場合は時間がかかります。
以下は、すべてのパスを更新するために実行する必要がある手順の擬似コードです。
すべてのレコードを取得し、データを抽出してパスを変更します
//Get all the records
Cursor allRecords = database.query(Table_Name, null, null, null, null, null, null);
//Extract the data from the Cursor and create a list
List<SomeDataObject> listOfModifiedDataObjects = new ArrayList<SomeDataObject>();
allRecords.moveToFirst();
while(!allRecords.isAfterLast())
{
int id = allRecords.getInt(allRecords.getColumnIndex("NameOfIDColumn"));
String description = allRecords.getString(allRecords.getColumnIndex("NameOfDescriptionColumn"));
//Modify the description to change the path of the src...
description = description.replace("allimages", "some/other/path/allimages");
//Create the data object and store it in the list
SomeDataObject tempObj = new SomeDataObject();
tempObj.ID = id;
tempObj.Description = description;
listOfModifiedDataObjects.add(tempObj);
}
変更されたデータでデータベースを更新します
注: これは、SQLiteDatabase オブジェクトにアクセスできるデータベース ヘルパー クラスで行う必要があります。
//Iterate through all the modified data objects
for(SomeDataObject curObj: listOfModifiedDataObjects)
{
ContentValues values = new ContentValues();
//Set the new description into the content values object
values.put("NameOfDescriptionColumn", curObj.Description);
//Update the table with the new value. The record that gets updated is based on the curObj.ID.
//In this case, I'm guessing your id column is named "_id"
database.update(TABLE_NAME, values, "_id = ?", new String[]{String.ValueOf(curObj.ID)});
}
私はこのコードをコンパイルしておらず、便利な IDE も持っていないため、小さなタイプミスがあるかもしれません。しかし、これで各レコードを更新する方法の一般的なアイデアが得られることを願っています。